crypto.createDiffieHellman() Method in Node.js

Mayank Agarwal
Updated on 15-Mar-2026 23:19:00

446 Views

The crypto.createDiffieHellman() method in Node.js creates a Diffie-Hellman key exchange object using a specified prime value and an optional generator. This method enables secure key exchange between two parties over an insecure channel. Syntax crypto.createDiffieHellman(prime, [primeEncoding], [generator], [generatorEncoding]) Parameters prime – The prime number used for the Diffie-Hellman exchange. Can be a number (bit length) or Buffer/string containing the prime value. primeEncoding ... Read More

How to set the border color of a selection area on a canvas using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

927 Views

In this article, we are going to learn how to set the border color of a selection area on a canvas using FabricJS. A selection indicates whether a group selection should be enabled or not. FabricJS allows us to adjust the border color accordingly with the selectionBorderColor property. Syntax new fabric.Canvas(element: HTMLElement|String, { selectionBorderColor: String }: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() or the id of the ... Read More

JavaScript: How to check if a number is NaN or finite?

Disha Verma
Updated on 15-Mar-2026 23:19:00

703 Views

Checking whether a number is NaN (Not a Number) or finite is important while working with numerical computations in JavaScript. NaN (Not a Number) indicates a value that can't be represented as a number, often occurring from invalid operations like dividing zero by zero (0/0). Finite numbers are all real numbers in JavaScript that are neither Infinity, -Infinity, nor NaN. JavaScript provides several built-in methods to determine if a value is NaN (Not a Number) or if a number is finite. In this article, you will understand how to check if a number is NaN or finite using these ... Read More

How to set the vertical scale factor of Circle using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

265 Views

In this tutorial, we are going to learn how to set the vertical scale factor of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. Just as we can specify the position, colour, opacity and dimension of a circle object in the canvas, we can also set the vertical scale of a circle object. This can be done by using the scaleY property. Syntax new fabric.Circle({ scaleY : Number }: ... Read More

What are the different use cases of remainder operator (%) in JavaScript?

Kalyan Mishra
Updated on 15-Mar-2026 23:19:00

514 Views

In this tutorial, we will explore the different use cases of the remainder operator (%). The % operator returns the remainder when one number is divided by another and takes the sign of the dividend (the first operand). What is Remainder? When dividing two numbers, if the dividend is not completely divisible by the divisor, there is always a remainder. The remainder is what's left over after the division. 10 ÷ 2 = 5 (remainder 0, completely divisible) 6 ÷ 4 = 1 (remainder 2, not completely divisible) The remainder operator works as: dividend ... Read More

How to get the coordinates of a Line object using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

951 Views

In this tutorial, we are going to show how you can get the coordinates of a Line using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the x and y coordinates of the line and adding it to the canvas. In order to get the coordinates of a Line object, we use the getCoords method. Syntax ... Read More

Remove property for all objects in array in JavaScript?

Yaswanth Varma
Updated on 15-Mar-2026 23:19:00

2K+ Views

Removing properties from all objects in an array is a common JavaScript task. You can accomplish this using either the delete operator (which mutates the original objects) or object destructuring with the rest operator (which creates new objects). A collection of key-value pairs constitutes an object in JavaScript. A key-value pair among them is referred to as an object property. Any data type, including Number, String, Array, Object, etc., can be used for both the keys and values of properties. Method 1: Using the delete Operator (Mutable) The delete operator removes both the property's value and the ... Read More

Finding average in mixed data type array in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

447 Views

Suppose, we have an array of mixed data types like this − const arr = [1, 2, 3, 4, 5, "4", "12", "2", 6, 7, "4", 3, "2"]; We are required to write a JavaScript function that takes in one such array and returns the average of all such elements that are a number or can be partially or fully converted to a number. The string "3454fdf", isn't included in the problem array, but if it wasn't there, we would have used the number 3454 as its contribution to average. Example The code ... Read More

Checking for permutation of a palindrome in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

714 Views

We are required to write a JavaScript function that takes in a string as the first and the only argument. The task of our function is to check whether any rearrangement in the characters of the string results into a palindrome string or not. If yes, then our function should return true, false otherwise. For a string to form a palindrome through rearrangement, at most one character can have an odd frequency. This is because palindromes read the same forwards and backwards. For example − If the input string is − const str = 'amadm'; ... Read More

Validating string with reference to array of words using JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

342 Views

We need to write a JavaScript function that takes an array of valid words and a string, then checks if the string can be formed by concatenating one or more words from the array. Problem Statement Given an array of words and a target string, determine if the string can be constructed using words from the array. Words can be reused multiple times. Input: const arr = ['love', 'coding', 'i']; const str = 'ilovecoding'; Expected Output: true The string "ilovecoding" can be formed by concatenating "i" + "love" + "coding". ... Read More

Advertisements