Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to set the border color of a selection area on a canvas using FabricJS?
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 MoreJavaScript: How to check if a number is NaN or finite?
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 MoreHow to set the vertical scale factor of Circle using FabricJS?
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 MoreWhat are the different use cases of remainder operator (%) in JavaScript?
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 MoreHow to get the coordinates of a Line object using FabricJS?
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 MoreRemove property for all objects in array in JavaScript?
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 MoreFinding average in mixed data type array in JavaScript
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 MoreChecking for permutation of a palindrome in JavaScript
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 MoreValidating string with reference to array of words using JavaScript
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 Morecrypto.createDiffieHellman(primeLength, [generator]) Method in Node.js
The crypto.createDiffieHellman(primeLength, [generator]) method creates a Diffie-Hellman key exchange object by generating a prime number of specified bit length. This is commonly used for secure key exchange between parties. Syntax crypto.createDiffieHellman(primeLength, [generator]) Parameters The parameters are described below: primeLength – The number of prime bits to generate. Must be a number. generator – Optional generator for creating the exchange key object. ...
Read More