Articles on Trending Technologies

Technical articles with clear explanations and examples

Difference Between Static and Const in JavaScript

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 4K+ Views

Static variables can be defined as a class property that is used in a class and not on the class instance. This type of variable is stored in the data segment area of the memory. The value assigned to these types of variables is shared among every instance that is created in the class. We need to use the static keyword for creating any static entity like a static variable, static function, operators, properties, etc. The value of a static variable is set at the runtime of the application and serves as a global value for the whole application. ...

Read More

How to set the padding of a Triangle using FabricJS?

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

In this tutorial, we are going to learn how to set the padding of 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. Just as we can specify the position, colour, opacity and dimension of a triangle object in the canvas, we can also set the padding of a triangle object. This can be done by using the padding property. Syntax new fabric.Triangle({ padding : Number }: Object) ...

Read More

How to get index in a sorted array based on iterator function in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 3K+ Views

When working with sorted arrays in JavaScript, you often need to find the correct insertion position for a new element to maintain the sorted order. This article explores different methods to achieve this using iterator functions. Using Binary Search for Insertion Index The most efficient approach is to implement a binary search algorithm that finds the insertion point without modifying the original array. function findInsertionIndex(arr, value, compareFunction) { let left = 0; let right = arr.length; while (left < ...

Read More

How to change the font size of Text using FabricJS?

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

In this tutorial, we are going to see how to change the font size of a Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. The font size specifies how large or small the characters, displayed in our Text object, should be. We can change the font size by using the fontSize property. ...

Read More

Is it possible to write data to file using only JavaScript?

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

In this tutorial, we will learn if it is possible to write data to files using only JavaScript. The short answer is: it depends on the environment. Pure client-side JavaScript running in browsers cannot directly write files to the user's system for security reasons. However, Node.js (server-side JavaScript) provides the fs module for file operations. Browser JavaScript Limitations Client-side JavaScript cannot write files directly due to security restrictions. Browsers prevent web pages from accessing the file system to protect users from malicious scripts. Node.js File Writing Node.js includes the fs (File System) module that handles ...

Read More

Similarities between different strings in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 203 Views

In JavaScript, finding similarities (intersections) between two arrays of strings is a common operation. We need to write a function that computes the intersection of two string arrays and returns elements that appear in both arrays. Problem Statement Given two arrays of strings, find the common elements that exist in both arrays. Each element in the result should appear as many times as it shows in both arrays. Example If we have these input arrays: arr1 = ['hello', 'world', 'how', 'are', 'you']; arr2 = ['hey', 'world', 'can', 'you', 'rotate']; The expected output ...

Read More

Find the smallest sum of all indices of unique number pairs summing to a given number in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 231 Views

This tutorial shows how to find pairs of numbers in an array that sum to a target value, then return the sum of all indices of these unique pairs. Problem Description Given an array of numbers and a target sum, we need to: Find all pairs of numbers that sum to the target Ensure each number is used only once across all pairs Return the sum of indices of all numbers used in valid pairs Example Walkthrough For array [1, 4, 2, 3, 0, 5] with target sum 7: Valid pairs: 4 ...

Read More

Using BigInt to calculate long factorials in JavaScript

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

In JavaScript, calculating factorials of large numbers requires the BigInt data type to avoid precision loss. BigInt handles arbitrarily large integers, making it perfect for computing long factorials that exceed JavaScript's standard number limits. What is BigInt? BigInt is a built-in JavaScript data type introduced in ECMAScript 2020 that represents integers of arbitrary size. Unlike the standard Number type, which has a maximum safe integer limit of 2^53 - 1, BigInt can handle infinitely large integers. // Regular numbers have limits console.log(Number.MAX_SAFE_INTEGER); // 9007199254740991 // BigInt can handle much larger values console.log(BigInt(Number.MAX_SAFE_INTEGER) * 100n); ...

Read More

Map anagrams to one another in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 280 Views

One array is an anagram of another if we can rearrange the elements of that array to achieve the other array. For example: [1, 2, 3] and [2, 1, 3] are anagrams of each other. We need to write a JavaScript function that takes two anagram arrays and returns a mapping array. The mapping array contains the index of each element from the first array as it appears in the second array. Problem Example If the two input arrays are: const arr1 = [23, 39, 57, 43, 61]; const arr2 = ...

Read More

Returning number with increasing digits. in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 221 Views

We are required to write a JavaScript function that takes in a number n. Our function should return it with its digits in descending order. Essentially, we should rearrange the digits to create the highest possible number. Problem Given a number, we need to arrange its digits in descending order to form the largest possible number from those digits. Solution The approach is to convert the number to a string, split it into individual digits, sort them in descending order, and then convert back to a number. Example const num = 5423267; ...

Read More
Showing 15571–15580 of 61,297 articles
Advertisements