Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a Rectangle with wait cursor on hover over objects using FabricJS?

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

In this tutorial, we are going to create a Rectangle with a wait cursor on hover over objects using FabricJS. wait is one of the native cursor styles available which can be used in the FabricJS canvas too. FabricJS provides various types of cursors like default, all-scroll, crosshair, col-resize, row-resize, etc., that reuse the native cursor under the hood. The hoverCursor property sets the style of the cursor when hovered over a canvas object. Syntax new fabric.Rect({ hoverCursor: String }: Object) Parameters Options ...

Read More

How to set the background colour of text lines with Text using FabricJS?

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

In this tutorial, we are going to learn how to set the background colour of text lines 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. Similarly we can also set the background colour of text lines by using the textBackgroundColor property. Syntax new fabric.Text(text: String , { textBackgroundColor ...

Read More

Apply an IF condition to every element in an HTML table with JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 5K+ Views

HTML tables are created using the tag with for table rows and for data cells. JavaScript allows you to apply conditional logic to each table element dynamically. This article demonstrates how to use JavaScript to apply if conditions to every element in an HTML table, enabling dynamic content modification based on specific criteria. Using document.querySelectorAll() with forEach() The document.querySelectorAll() method returns a static NodeList of all elements matching the specified CSS selector. Combined with forEach(), it allows you to iterate through table elements and apply conditions. Syntax document.querySelectorAll(selector).forEach(function(element) { ...

Read More

Make strings in array become keys in object in a new array in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

The task we are going to perform in this article is to make strings in an array become keys in objects within a new array in JavaScript. Let's consider a simple array: let array = ['bike', 'car']; We want to transform this array into a new array where each string becomes a key in an object with an empty array as its value: let newArray = [{bike: []}, {car: []}]; Let's explore different methods to accomplish this transformation in JavaScript. Using map() Method The map() method creates a new array ...

Read More

Reduce array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 243 Views

In JavaScript, arrays can be transformed using various methods. This article demonstrates how to extract and convert time values from an array of objects into a more usable format. Suppose we have an array of objects containing time strings: const arr = [ {"time":"18:00:00"}, {"time":"10:00:00"}, {"time":"16:30:00"} ]; We need to create a function that: Extracts the time strings from each object Converts times like "18:00:00" to arrays like [18, 0] Returns an array containing all converted time arrays Using map() to Transform ...

Read More

Finding all possible ways of integer partitioning in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 816 Views

The partition of a positive integer n is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same partition. For example, 4 can be partitioned in five distinct ways: 4 3 + 1 2 + 2 2 + 1 + 1 1 + 1 + 1 + 1 We are required to write a JavaScript function that takes in a positive integer as the only argument. The function should find and return all the possible ways of partitioning that ...

Read More

All ways of balancing n parenthesis in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 201 Views

Problem We are required to write a JavaScript function that takes in a number n. Our function should return an array showing all the ways of balancing n parenthesis. For example, for n = 3, the output will be: ["()()()", "(())()", "()(())", "(()())", "((()))"] Approach We use a recursive backtracking approach where we keep track of how many opening and closing parentheses we can still use. At each step, we can add an opening parenthesis if we have any left, or a closing parenthesis if it would create a valid balance. Example ...

Read More

Finding the sum of all common elements within arrays using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 336 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
Showing 11731–11740 of 61,303 articles
Advertisements