Articles on Trending Technologies

Technical articles with clear explanations and examples

Adding a unique id for each entry in JSON object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 5K+ Views

In this problem statement, our task is to add a unique id for every object entry in a JSON object with the help of JavaScript. We will use a loop and a variable to store the id for each object in the JSON object. Understanding the Problem Statement The problem statement is to write a function in JavaScript that adds a unique id to every item in the given JSON object. For example, if we have: let obj = { "entry1": {empName: "A", age: 25}, "entry2": {empName: "B", age: 30} ...

Read More

Finding the nth prime number in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 6K+ Views

In this article, we'll learn how to find the nth prime number using JavaScript. A prime number is a positive integer greater than 1 that has no divisors other than 1 and itself. Understanding the Problem We need to create a JavaScript function that takes an input n and returns the nth prime number. For example, if n=5, we should return 11 (the 5th prime number in the sequence: 2, 3, 5, 7, 11). Algorithm Approach We'll use a two-step approach: Helper Function: Create an isPrime() function to check if a number is prime ...

Read More

How to set the background color of selection of Ellipse using FabricJS?

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

In this tutorial, we are going to learn how to set the background color of selection of an Ellipse using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we have to create an instance of fabric.Ellipse class and add it to the canvas. We can change an objects dimensions, rotate it or manipulate it when it is actively selected. We can change the background color of selection of Ellipse by using the selectionBackgroundColor property. Syntax new fabric.Ellipse({ selectionBackgroundColor : String }: Object) Parameters ...

Read More

How to add stroke to a Triangle using FabricJS?

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

In this tutorial, we are going to learn how to add stroke to a Triangle using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. Our triangle object can be customized in various ways like changing its dimensions, adding a background colour or by changing the colour of the line drawn around the object. We can do this by using the stroke property. Syntax new fabric.Triangle({ stroke: String }: Object) ...

Read More

How to make the controlling corners of a Textbox transparent using FabricJS?

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

In this tutorial, we are going to learn how to make the controlling corners of a Textbox transparent using FabricJS. We can customize, stretch or move around the text written in a textbox. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. The transparentCorners property allows us to make the controlling corners of Textbox transparent. Syntax new fabric.Textbox(text: String, { transparentCorners: Boolean }: Object) Parameters text − This parameter accepts a String which is the text ...

Read More

How to change the colour of cursor in IText using FabricJS?

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

In this tutorial, we are going to learn about how to change the colour of cursor in IText object using FabricJS. The IText class was introduced in FabricJS version 1.4, extends fabric.Text and is used to create IText instances. An IText instance gives us the freedom to select, cut, paste or add new text without additional configurations. There are also various supported key combinations and mouse/touch combinations which make text interactive which are not provided in Text. Textbox, however, which is based on IText allows us to resize the text rectangle and wraps lines automatically. This is not true ...

Read More

How to Develop Generic Classes

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 279 Views

Generic classes in TypeScript allow you to create flexible, reusable classes that can work with multiple data types. They use type parameters enclosed in angle brackets () to represent the type of data the class will handle, making your code more versatile and type-safe. A generic class uses type parameters (commonly denoted as "T") as placeholders for actual types. When you instantiate the class, you specify the concrete type, and the class properties and methods adapt accordingly. This approach eliminates code duplication while maintaining type safety. Syntax The basic syntax for creating a generic class in TypeScript ...

Read More

Sort array of objects by string property value in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 3K+ Views

The given task is to sort an array of objects by using string property value in JavaScript. Assume there is an array of objects and we need to sort those elements by using the string property. In this below scenario, we are sorting array of objects by "Company" property. const array = [ {Company: 'Oneplus', Manufacturing: 'China'}, {Company: 'Samsung', Manufacturing: 'South korea'}, {Company: 'Nothing', Manufacturing: 'India'} ]; // Output after sorting by "Company" property: [ {"Company":"Nothing", "Manufacturing":"India"}, {"Company":"Oneplus", "Manufacturing":"China"}, ...

Read More

JavaScript in filter an associative array with another array

Shriansh Kumar
Shriansh Kumar
Updated on 15-Mar-2026 1K+ Views

In this article, we'll explore how to filter an associative array using another array in JavaScript. This is a common task when you need to extract specific objects from a dataset based on matching criteria. What is an Associative Array? An associative array is a data structure that stores key-value pairs. Each key is associated with a specific value and serves as a unique identifier. Unlike regular arrays, associative arrays don't use numeric indexes—keys can be strings or numbers. In JavaScript, objects function as associative arrays since they store key-value pairs where keys can be strings or ...

Read More

How to get almost increasing sequence of integers in JavaScript ?

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

In JavaScript, an almost increasing sequence is a sequence where most elements are in non-decreasing order, with at most one element that breaks this pattern. This article demonstrates how to generate such sequences programmatically. Understanding the Problem An almost increasing sequence allows for exactly one "violation" where an element might be smaller than its predecessor. For example, [1, 3, 2, 5, 6] is almost increasing because only one element (2) breaks the increasing pattern. Our goal is to generate such sequences randomly in JavaScript. Algorithm Approach We'll create a function that generates a mostly increasing sequence ...

Read More
Showing 14911–14920 of 61,297 articles
Advertisements