Articles on Trending Technologies

Technical articles with clear explanations and examples

Finding the sum of all common elements within arrays using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 348 Views

Problem We are required to write a JavaScript function that takes in three arrays of numbers. Our function should return the sum of all those numbers that are common in all three arrays. Example Following is the code − const arr1 = [4, 4, 5, 8, 3]; const arr2 = [7, 3, 7, 4, 1]; const arr3 = [11, 0, 7, 3, 4]; const sumCommon = (arr1 = [], arr2 = [], arr3 = []) => { let sum = 0; for(let i = 0; i ...

Read More

process.cpuUsage() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 1K+ Views

The process.cpuUsage() method returns CPU time consumption information for the current Node.js process. It provides data about user and system CPU time in microseconds (10^-6 seconds). Syntax process.cpuUsage([previousValue]) Parameters previousValue – Optional parameter. A previous return value from calling process.cpuUsage() to calculate the difference in CPU usage. Return Value Returns an object with two properties: user – CPU time spent in user code (microseconds) system – CPU time spent in system calls (microseconds) Example: ...

Read More

How to Remove Duplicate Elements from an Array in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 2K+ Views

To remove duplicate elements from an array in JavaScript can be achieved using various approaches. We will be understanding six different approaches in this article, which can be used according to our requirement in various cases. In this article we are having a JavaScript array and our task is to remove duplicate elements from array in JavaScript. Original Array: ["apple", "banana", "apple", "orange", "banana", "grape"] ...

Read More

How to disable the centered rotation of Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to disable the centered rotation of Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. By default, all objects in FabricJS use their center as the point of rotation. However, we can change this behaviour by using the centeredRotation property. Syntax new fabric.Rect({ centeredRotation: Boolean }: Object) Parameters ...

Read More

How to set the baseline of subscript with Text using FabricJS?

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

In this tutorial, we are going to learn how to set the baseline of subscript with Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can also use the subscript property where we can specify its baseline value. Syntax new fabric.Text(text: String , { subscript : {"size": Number, "baseline": ...

Read More

How to add fade-in effect using pure JavaScript?

Diksha Patro
Diksha Patro
Updated on 15-Mar-2026 7K+ Views

Introduction We use the fade effect to bring attention to certain parts of our website by gradually increasing or decreasing their opacity. This gradual change in opacity is called the fade-in or fade-out effect. When we gradually increase the opacity, it's known as the fade-in effect and is used to make the selected part of the page become more visible over a chosen amount of time. This creates a smooth transition and helps make our website more dynamic and engaging for our users. In this article, we will be exploring two ways in which we can implement the ...

Read More

Calculate Subtraction of diagonals-summations in a two-dimensional matrix using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 292 Views

Suppose we have a square matrix represented by a 2-D array in JavaScript like this: const arr = [ [1, 3, 5], [3, 5, 7], [2, 4, 2] ]; console.log(arr); [ [ 1, 3, 5 ], [ 3, 5, 7 ], [ 2, 4, 2 ] ] We need to write a JavaScript function that calculates the absolute difference between the sum of elements on the two diagonals of the matrix. Understanding the Diagonals In a square matrix, there are two diagonals: ...

Read More

Repeat String in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 192 Views

JavaScript provides multiple ways to repeat a string. The most modern approach is using the built-in repeat() method, but you can also use older techniques like Array.join(). Using String.repeat() (Recommended) The String.repeat() method is the standard way to repeat strings in modern JavaScript: String Repeat Example let str = "Hello "; let repeated = str.repeat(3); console.log(repeated); ...

Read More

Hide a video tag on a web page - JavaScript

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

In JavaScript, you can hide a video element on a web page by setting its display CSS property to "none" using the style.display property. Let's say we have the following sample video tag on a web page: You cannot play video here...... Syntax To hide a video element, use the following syntax: element.style.display = "none"; Method 1: Hide by Class Name This method selects the video element by its class name and hides it: ...

Read More

JavaScript - Merge two arrays according to id property

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

When working with JavaScript arrays of objects, you often need to merge two arrays based on a common property like an ID. This is useful for combining related data from different sources, such as user profiles and addresses. Suppose we have two arrays of objects. The first contains user IDs and names, while the second contains user IDs and addresses: const arr1 = [ {"id":"123", "name":"name 1"}, {"id":"456", "name":"name 2"} ]; const arr2 = [ {"id":"123", "address":"address 1"}, {"id":"456", "address":"address 2"} ...

Read More
Showing 16081–16090 of 61,297 articles
Advertisements