Articles on Trending Technologies

Technical articles with clear explanations and examples

Adding rotation animation to a Polygon object using FabricJS

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. 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 add rotation animation, we can use the angle property in conjunction with animate method. Syntax animate(property: String | Object, value: Number | Object): fabric.Object | fabric.AnimationContext | Array. Parameters ...

Read More

How to implement copy paste programmatically using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 1K+ Views

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. 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 implement copy paste programmatically, we need to use the clone method. Syntax clone(callback: Function, propertiesToInclude: Array) Parameters callback (optional) − This parameter is a callback function which is invoked with a clone as its ...

Read More

How to change the ID of the element using JavaScript?

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

Generally, the ID given to any element in an HTML document is unique and can be assigned to an element only once. However, it is possible to change that ID later using JavaScript while following the same rule of uniqueness for the new ID. In this article, we will learn how to change the ID of an element using JavaScript. JavaScript provides the id property to get the ID of any element as well as to change or add a new ID to any HTML element in the document. Syntax The following syntax shows how to use ...

Read More

How to set a String as a key for an object - JavaScript?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 6K+ Views

In JavaScript, it is common to use a string as a key for an object, especially when you want to dynamically create or change the properties of the object. Objects are fundamental data structures that allow you to store collections of data in key-value pairs. You can use strings as keys directly. It is a simple and straightforward method. This article will guide you how to use a string as a key for an object. Using Computed Property Names (ES6) The most modern approach is using computed property names with bracket notation inside the object literal. This allows ...

Read More

Creating permutations to reach a target number, but reuse the provided numbers JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 218 Views

We are required to write a JavaScript function that takes in an array of Numbers as the first argument and a target sum Number as the second argument. The function should return an array of all those subarrays from the original array whose elements sum to make the target sum. We can use a single number multiple times to achieve the sum. For example − If the input array and number are − const arr = [1, 2, 4]; const sum = 4; then the output should be − [ ...

Read More

Transform data from a nested array to an object in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 844 Views

Suppose, we have the following array of arrays: const arr = [ [ ['dog', 'Harry'], ['age', 2] ], [ ['dog', 'Roger'], ['age', 5] ] ]; We are required to write a JavaScript function that takes in one such nested array. The function should then prepare an object based on the array. The object for the above array should look like: const output = [ {dog: 'Harry', ...

Read More

Finding median for every window in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 942 Views

In mathematics, the median is the middle value in an ordered (sorted) list of numbers. If the list has an even number of elements, the median is the average of the two middle values. Problem Statement We need to write a JavaScript function that takes an array of integers and a window size, then calculates the median for each sliding window of that size. The function returns an array containing all the calculated medians. For example, given: const arr = [5, 3, 7, 5, 3, 1, 8, 9, 2, 4, 6, 8]; const windowSize = ...

Read More

How to convert 3-digit color code to 6-digit color code using JavaScript?

Kalyan Mishra
Kalyan Mishra
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will see how to convert 3-digit color code to 6-digit color code in JavaScript. A 3-digit hex color code represents colors in #RGB format, where each digit controls red, green, and blue values. To convert to 6-digit format, we duplicate each character: #RGB becomes #RRGGBB. For example: 3-digit: #08c 6-digit: #0088cc 3-digit: #f4a 6-digit: #ff44aa Algorithm Step 1: Check if the input length is exactly 3 characters Step 2: Split the string into individual characters using split("") Step 3: Use map() to duplicate each character ...

Read More

How to change the shape of a textarea using JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 491 Views

A textarea is an HTML element that provides a multi-line text input field with dynamic width and height. By default, textareas appear as rectangular boxes, but you can change their shape using JavaScript to modify CSS properties. In this article, we'll explore different methods to transform textarea shapes using JavaScript, including creating parallelograms and ellipses through CSS property manipulation. Using transform Property for Parallelogram Shape The transform property with skew() function can transform a rectangular textarea into a parallelogram by skewing it along the X or Y axis. Syntax element.style.transform = "skew(angle)"; ...

Read More

How to convert a string with zeros to number in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 455 Views

When you have a string containing numbers with dots or zeros as separators, you can convert it to a number using JavaScript's built-in methods. This is commonly needed when processing formatted numeric data. The Problem Consider a string like "453.000.00.00.0000" where dots are used as thousand separators rather than decimal points. Direct conversion methods like Number() won't work correctly because JavaScript interprets the first dot as a decimal separator. let stringValue = "453.000.00.00.0000"; console.log("Original string:", stringValue); console.log("Direct Number() conversion:", Number(stringValue)); // NaN Original string: 453.000.00.00.0000 Direct Number() conversion: NaN Using parseInt() ...

Read More
Showing 14391–14400 of 61,297 articles
Advertisements