Articles on Trending Technologies

Technical articles with clear explanations and examples

FabricJS – How to remove the current object shadow in a cloned image?

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

In this tutorial, we are going to learn how to remove the current object shadow in a cloned image 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 remove the current object shadow in a cloned image, we use the withoutShadow property. Syntax cloneAsImage( callback: function, { withoutShadow: Boolean }: Object): fabric.Object Parameters callback (optional) − This parameter ...

Read More

Explain Promise.any() with async-await in JavaScript?

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

We will learn about the Promise.any() method in JavaScript and how to use it with async/await. In JavaScript, promises handle asynchronous operations, making applications faster by allowing code execution without waiting for slow operations to complete. What is Promise.any()? The Promise.any() method returns the first successfully resolved promise from an array of promises. It ignores rejected promises and only fails if all promises are rejected (throwing an AggregateError). Syntax Promise.any(iterable) .then(value => { // Handle first resolved value }) .catch(error => { ...

Read More

Explain the differences in the usage of foo between function foo() {} and var foo = function() {}

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

In JavaScript, there are two primary ways to define functions: function declarations and function expressions. While both achieve similar results, they behave differently in terms of hoisting and evaluation timing. Function Declaration: function foo() {} Function declarations use the function keyword followed by the function name. They are hoisted to the top of their scope, meaning you can call them before they're defined in the code. Syntax function foo(parameters) { // function body } Example: Basic Function Declaration ...

Read More

How to avoid dropdown menu to close menu items on clicking inside?

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

We can use the preventDefault() method to prevent the default behavior of the click event on the dropdown menu. By doing this, the menu items will not close when clicked inside. Additionally, we can add a click event listener to the dropdown menu and set the event.stopPropagation() method to stop the event from propagating to parent elements. HTML Dropdown HTML dropdown is a type of form element that allows users to select one option from a list of options. It is created using the select and option tags in HTML. The "select" tag defines the dropdown container and ...

Read More

How to convert NaN to 0 using JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 4K+ Views

We can use the logical OR operator, double bitwise NOT operator, strict equality operator, or the isNaN() function to convert NaN to 0 using JavaScript. NaN in JavaScript means Not a Number, whose type is Number but actually, it is not a number. In this article, we will learn different approaches to convert NaN to 0. Using the Logical OR (||) Operator Using the Double Tilde (~~) Operator Using the Strict Equality (===) Operator Using the isNaN() function Using the Logical OR (||) Operator ...

Read More

How to get all combinations of some arrays in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 368 Views

Getting all combinations of arrays in JavaScript can be accomplished using recursive generator functions or iterative approaches. This is useful for creating permutations, product combinations, and other algorithmic solutions. Using Generator Function (Cartesian Product) A generator function can efficiently create all combinations by recursively building each possibility: function getAllCombinations(values) { function* generateCombinations(size, current) { if (size) { for (var element of values) { ...

Read More

Best way to flatten an object with array properties into one array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 884 Views

When you have an object containing arrays as values, you often need to flatten all these arrays into a single array. This is a common operation when working with grouped data. const obj = { arr_a: [9, 3, 2], arr_b: [1, 5, 0], arr_c: [7, 18] }; console.log("Original object:", obj); Original object: { arr_a: [ 9, 3, 2 ], arr_b: [ 1, 5, 0 ], arr_c: [ 7, 18 ] } The goal is to merge all array values into one ...

Read More

Numbers smaller than the current number JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 641 Views

In JavaScript, we often need to count how many numbers in an array are smaller than each element. This problem requires comparing each element against all others to build a result array showing the count of smaller numbers for each position. Understanding the Problem Given an array of integers, we need to return a new array of the same length where each element represents the count of numbers smaller than the corresponding element in the original array. For example: if we have [5, 4, 3, 2, 1], the output should be [4, 3, 2, 1, 0] because: ...

Read More

Finding all duplicate numbers in an array with multiple duplicates in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 892 Views

In JavaScript, finding duplicate numbers in an array is a common task that can be efficiently solved using objects to track element frequencies. This approach helps identify all numbers that appear more than once in the array. Understanding the Problem We need to find all duplicate numbers in an array that may contain multiple duplicates. For example, given the array [1, 1, 4, 8, 2, 2, 6, 6, 6], the duplicate numbers are [1, 2, 6] since these appear more than once. Using Object to Count Frequencies The most efficient approach uses an object to count ...

Read More

Finding the elements of nth row of Pascal's triangle in JavaScript

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

Pascal's triangle is a triangular array constructed by summing adjacent elements in preceding rows. Each row starts and ends with 1, and each interior element is the sum of the two elements above it. The first few rows of Pascal's triangle are: 1 1 1 1 2 1 1 3 3 1 ...

Read More
Showing 15081–15090 of 61,297 articles
Advertisements