Articles on Trending Technologies

Technical articles with clear explanations and examples

What are the Important Array Methods in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 268 Views

In this article, we are going to explore different methods provided by Array and their importance in JavaScript. We will learn how to use them and what are their actual use cases with the help of examples. Before moving on to methods, below is the syntax for creating an array in JavaScript: let array = [element1, element2, ...]; Alternatively, we can also define the array as follows: let array = new Array(element1, element2, ...); Basic Array Methods (Adding/Removing Elements) These methods are essential for manipulating array contents: ...

Read More

How to return a passed string with letters in alphabetical order in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 2K+ Views

We can apply String split(), Array sort() and Array join() methods to write a function that returns a passed string with letters in alphabetical order in JavaScript. This approach converts the string into an array, sorts the characters, and joins them back into a string. Input string : tutorialspoint Output string: aiilnooprstttu Syntax function sortString(str) { return str.split("").sort().join(""); } Steps Split the string into an array of characters using split("") method. ...

Read More

How to center an Image object horizontally on current viewport of canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 491 Views

In this tutorial, we are going to learn how to center an Image object horizontally on current viewport of canvas using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to center an Image object horizontally on current viewport of canvas, we use the viewportCenterH method. Syntax viewportCenterH(): fabric.Object Default appearance of the Image object Let's see a code example to see how our Image ...

Read More

How to create a Polygon with Polyline using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 1K+ Views

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Since Polygon extends fabric.Polyline, we can create a polygon instance by using polyline as well. Syntax new fabric.Polyline( points: Array, options: Object ) Parameters points − This parameter accepts an Array which denotes the array ...

Read More

JavaScript knowledge required for GTM (Google Tag Manager)

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 855 Views

The Google Tag Manager (GTM) is a tag management system that allows you to configure and rapidly deploy tags on your website or mobile app using a simple web-based interface. It has the same capabilities as the Google Tag, a JavaScript library used to send data from your website to Google Analytics. Tag Manager also supports tag version management and organization, community and third-party-developed tag templates, enterprise collaboration tools, and security features. JavaScript for Google Tag Manager Before you start using Google Tag Manager effectively, understanding these JavaScript fundamentals is essential: Basic ...

Read More

How to clear the content of a div using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 16K+ Views

We will learn to remove all child elements or content of a div element using JavaScript. However, whatever method we learn to clear the div element's content will work with any HTML element. Removing the content of the div element is useful when users want to display some HTML content based on a particular condition or want to replace HTML content. Here, we will explore three approaches to clear the content of a div using JavaScript. Using the replaceChildren() Method The replaceChildren() method allows developers to replace child elements of a particular HTML element. When called ...

Read More

Remove/ filter duplicate records from array - JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 318 Views

JavaScript arrays often contain duplicate records that need to be removed. There are several effective methods to filter duplicates, depending on whether you're working with primitive values or objects. Sample Data with Duplicates Let's start with an array of nationality objects containing duplicate values: var objectOfNationality = [ { nationality: "Indian" }, { nationality: "American" }, { nationality: "Emirati" }, { nationality: "Indian" }, { nationality: "American" } ]; console.log("Original array:", objectOfNationality); ...

Read More

Finding the majority element of an array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 897 Views

We are given an array of size n, and we are required to find the majority element. The majority element is the element that appears more than [ n/2 ] times. Example const arr = [2, 4, 2, 2, 2, 4, 6, 2, 5, 2]; const majorityElement = (arr = []) => { const threshold = Math.floor(arr.length / 2); const map = {}; for (let i = 0; i < arr.length; i++) { const value = arr[i]; ...

Read More

JavaScript Program to Find Common Elements in Two Sorted Arrays

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 673 Views

To find common elements in two sorted arrays using JavaScript, we will be discussing various approaches. Common element refers to element which is present in both the arrays. First, we will try brute force approach and then we will optimize our code to improve the time complexity. In this article we are having two sorted arrays, our task is to find common elements in two sorted arrays. Users must already know about JavaScript arrays, its function and operations on arrays, loops, searching technique and conditional statement. ...

Read More

Implementing custom function like String.prototype.split() function in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

We need to create a custom function that behaves like the built-in String.prototype.split() method. This function will split a string into an array based on a separator character or string. Problem Statement We are required to write a JavaScript function that extends the String prototype. The function should take a string separator as an argument and return an array of parts where the original string is split by that separator. Implementation Here's how to implement a custom split function: String.prototype.customSplit = function(sep = '') { const res = []; ...

Read More
Showing 16571–16580 of 61,297 articles
Advertisements