Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create asynchronous function in TypeScript?

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

Asynchronous programming allows us to perform multiple tasks without blocking code execution. In TypeScript, we use the async/await keywords to create asynchronous functions that handle promises elegantly. Before diving in, let's understand why asynchronous programming is essential. When fetching data from APIs or performing I/O operations, these tasks take time to complete. In single-threaded languages like TypeScript and JavaScript, synchronous code would block execution until the operation finishes, leading to poor performance. Asynchronous functions solve this by allowing other code to execute while waiting for time-consuming operations to complete. The await keyword pauses execution only within the async ...

Read More

Counting smaller and greater in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 420 Views

In JavaScript, we often need to count elements in an array that are greater than or smaller than a specific value. This is useful for data analysis, filtering, and statistical operations. Let's say we have an array of numbers and want to count how many elements are greater than and smaller than a given number n. const arr = [3, 5, 5, 2, 23, 4, 7, 8, 8, 9]; console.log("Array:", arr); Array: [3, 5, 5, 2, 23, 4, 7, 8, 8, 9] Using reduce() Method The most elegant approach uses the ...

Read More

Regroup JSON array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 387 Views

Suppose, we have a JSON array of objects like this − const arr = [ { "id": "03868185", "month_10": 6, }, { "id": "03870584", "month_6": 2, }, { "id": "03870584", ...

Read More

Algorithm to get the combinations of all items in array JavaScript

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

In this problem statement, our task is to get the combinations of all items in an array with the help of Javascript functionalities. We can use a recursive approach that iteratively adds items to a running list of combinations. Understanding the Problem The goal is to write a function in Javascript that finds all possible combinations of elements in an array. For example, if we have an array [1, 2, 3], the combinations would be: [ [], [1], [2], [3], [1, 2], [1, ...

Read More

Finding the largest prime factor of a number in JavaScript

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

In JavaScript, finding the largest prime factor of a number involves dividing the number by its prime factors until we reach the highest one. This is commonly solved using prime factorization. Understanding Prime Factors A prime factor is a prime number that divides the given number exactly (without remainder). For example, the number 84 has prime factors: 2, 2, 3, and 7. Among these, 7 is the largest prime factor. Algorithm Approach We use prime factorization by starting with ...

Read More

Integers have sum of squared divisors as perfect square in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 347 Views

Problem We need to write a JavaScript function that takes a range specified by two numbers m and n, and finds all integers between m and n where the sum of their squared divisors is itself a perfect square. The function should return an array of subarrays, where each subarray contains the number and the sum of its squared divisors. Understanding the Concept For a number to qualify, we need to: Find all divisors of the number Square each divisor and sum them up ...

Read More

How to set the angle of skew on X-axis of Ellipse using FabricJS?

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

In this tutorial, we are going to learn how to set the angle of skew on X-axis of an Ellipse using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we will create an instance of fabric.Ellipse class and add it to the canvas. Our ellipse object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on X-axis. We can do this by using the skewX property. Syntax new fabric.Ellipse({ skewX : Number }: Object) ...

Read More

How to lock the vertical movement of Textbox using FabricJS?

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

In this tutorial, we are going to learn how to lock the vertical movement of a Textbox using FabricJS. Just as we can specify the position, colour, opacity and dimension of a textbox object in the canvas, we can also specify whether we want it to move only in the X-axis. This can be done by using the lockMovementY property. Syntax new fabric.Textbox(text: String, { lockMovementY: Boolean }: Object) Parameters text − This parameter accepts a String which is the ...

Read More

How to add underline in IText using FabricJS?

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

In this tutorial, we are going to learn how to add underline to IText 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 for IText as height is ...

Read More

Special type of sort of array of numbers in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 182 Views

We are required to write a JavaScript function that takes in an array of numbers and sorts the array such that first all the even numbers appear in ascending order and then all the odd numbers appear in ascending order. For example: If the input array is − const arr = [2, 5, 2, 6, 7, 1, 8, 9]; Expected Output Then the output should be − [2, 2, 6, 8, 1, 5, 7, 9] Using Custom Comparator Function We can solve this by creating a custom comparator function ...

Read More
Showing 14881–14890 of 61,297 articles
Advertisements