Articles on Trending Technologies

Technical articles with clear explanations and examples

How to add superscript with Text using FabricJS?

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

In this tutorial, we are going to learn how to add superscript with 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. We can also add superscripts by using the setSuperscript method. Syntax setSuperscript(start: Number, end: Number) Parameters start − This parameter accepts a Number as ...

Read More

How does Promise.all() method differs from Promise.allSettled() method in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 286 Views

In this article, you will understand how Promise.all() method differs from the Promise.allSettled() method in JavaScript. The Promise.all() method takes one or multiple promises as input and returns a single Promise. This returned promise fulfills when all of the input promises are fulfilled. It rejects immediately when any of the input promises is rejected, with this first rejection reason. The Promise.allSettled() method takes one or multiple promises as input and returns a single Promise. This returned promise fulfills when all of the input promises settle (either fulfilled or rejected), returning an array of objects that describe the outcome ...

Read More

How to Create a Tab Image Gallery?

Prerna Tiwari
Prerna Tiwari
Updated on 15-Mar-2026 3K+ Views

Creating a tab image gallery is a great way to showcase collections of images on a website. This tutorial will guide you through building a fully functional tab gallery using HTML, CSS, and JavaScript. Each tab will display a different set of images, making it perfect for organizing photos, artwork, or product galleries. Step 1: Create the HTML Structure First, we need to create the HTML structure for our tab gallery. We'll use a container div for the tabs and another container for the image content areas. Nature Architecture ...

Read More

Constructing array from string unique characters in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 193 Views

We are required to write a JavaScript function that takes in a string and starts mapping its characters from 0. And every time, the function encounters a unique (non-duplicate) character it should increase the mapping count by 1 otherwise it should map the same number for duplicate characters. For example: If the string is − const str = 'heeeyyyy'; Then the output should be − const output = [0, 1, 1, 1, 2, 2, 2, 2]; Therefore, let's write the code for this function − Example The code ...

Read More

Array filtering using first string letter in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Suppose we have an array that contains names of some people like this: const arr = ['Amy', 'Dolly', 'Jason', 'Madison', 'Patricia']; console.log(arr); [ 'Amy', 'Dolly', 'Jason', 'Madison', 'Patricia' ] We are required to write a JavaScript function that takes in one such array as the first argument, and two lowercase alphabet characters as second and third arguments. Then, our function should filter the array to contain only those elements that start with alphabets that fall within the range specified by the second and third arguments. Therefore, if the second and third arguments ...

Read More

Sorting an integer without using string methods and without using arrays in JavaScript

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

In this problem, we need to sort the digits of an integer number without using string methods or arrays in JavaScript. We'll use mathematical operations and loops to extract, compare, and rearrange digits. Understanding the Problem Sorting an integer means arranging its digits in ascending or descending order. For example, if we have the number 784521, the sorted result would be 124578 (ascending) or 875421 (descending). We need to achieve this using only mathematical operations without converting to strings or using arrays. Algorithm Overview Our approach involves two main functions: sortInteger() - Main function ...

Read More

Swapping string case using a binary number in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 250 Views

We need to write a JavaScript function that takes a string and a number, then uses the binary representation of the number to determine which alphabetic characters should have their case swapped. Problem Each bit in the binary representation of the number specifies whether to swap the case for each alphabetic character: If the bit is 1, swap the case (lowercase → uppercase, uppercase → lowercase) If the bit is 0, leave the character as is When we reach the end of the binary representation, start again from the first bit Non-alphabetic characters remain unchanged ...

Read More

Returning a decimal that have 1s in its binary form only at indices specified by array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 167 Views

Problem We are required to write a JavaScript function that takes in an array of unique non-negative integers. Our function should return a 32-bit integer such that the integer, in its binary representation, has 1 at only those indexes (counted from right) which are in the sequence. Example Following is the code − const arr = [1, 2, 0, 4]; const buildDecimal = (arr = []) => { const bitArr = Array(31).fill(0); let res = 0; arr.forEach(el => { ...

Read More

Smallest possible length constituting greatest frequency in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 220 Views

This problem asks us to find the smallest contiguous subarray that contains the maximum frequency of any element found in the entire array. We need to track element frequencies and their position ranges to determine the shortest span. Problem Understanding Given an array, we must: Find the maximum frequency of any element in the entire array Identify the shortest contiguous subarray where some element appears with this maximum frequency Return the length of this shortest subarray Example Walkthrough For the array [55, 77, 77, 88, 55]: Element 55 appears twice (positions 0 and ...

Read More

Creating an Agent in Node.js

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

In Node.js, an HTTP Agent manages connection pooling for HTTP client requests. You can create a custom agent using the new Agent() constructor to control connection behavior like keep-alive settings and socket limits. Syntax new http.Agent({options}) Parameters The Agent constructor accepts an options object with the following configurable properties: keepAlive – Keeps sockets open for reuse instead of closing them after each request. Default: false ...

Read More
Showing 15501–15510 of 61,297 articles
Advertisements