Articles on Trending Technologies

Technical articles with clear explanations and examples

Sum excluding one element in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 820 Views

In JavaScript, when you need to find the minimum and maximum possible sums by excluding exactly one element from an array, you can solve this efficiently using a single loop approach. The key insight is that to get the minimum sum (excluding one element), you remove the largest element. To get the maximum sum (excluding one element), you remove the smallest element. Problem Statement Given an array of integers, return an array with two values: First integer: smallest possible sum excluding any one element Second integer: greatest ...

Read More

How to disable the selectability of Circle using FabricJS?

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

In this tutorial, we are going to learn how to disable selectability of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. In order to modify an object, we have to select it in FabricJS. However, we can change this behaviour by using the selectable property. Syntax new fabric.Circle({ selectable: Boolean }: Object) Parameters ...

Read More

How to set the alignment of text in a Textbox using FabricJS?

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

In this tutorial, we are going to learn how to set the alignment of text in a Textbox 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. Similarly, we can also set its text alignment by using the textAlign property. Syntax new fabric.Textbox(text: String, { textAlign : String }: Object) Parameters text − This parameter accepts a String which is the text string that we ...

Read More

How to find the original size of an Image using FabricJS?

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

In this tutorial, we are going to learn how to find the original size of an Image using FabricJS. We can create an Image object by creating an instance of fabric.Image. 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 find the original size of an Image, we use the getOriginalSize method. Syntax getOriginalSize(): Object Return Value The method returns an object containing the width and height of the original image in pixels: { ...

Read More

How to Enforce the type of the indexed members of a Typescript object

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

TypeScript is a strongly typed, object-oriented programming language built on JavaScript. One of its powerful features is the ability to enforce types of an object's indexed members using index signatures. This allows you to define the shape of objects with dynamic properties while maintaining type safety. An index signature specifies the types for both keys and values in an object. It's particularly useful when you need objects with unknown property names but known value types. Syntax interface ObjectType { [key: string]: ValueType; } // Or inline let objectName: { [key: string]: ...

Read More

Finding smallest number that satisfies some conditions in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 273 Views

We are required to write a JavaScript function that takes in a number as the first argument, say n, and an array of numbers as the second argument. The function should return the smallest n-digit number which is a multiple of all the elements specified in the array. If there exist no such n-digit element then we should return the smallest such element. For example: If the array is − const arr = [12, 4, 5, 10, 9] For both n = 2 and n = 3, we need to find the smallest number ...

Read More

Push specific elements to last in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 207 Views

Suppose we have an array of objects like this: const arr = [ {flag: true, other: 1}, {flag: true, other: 2}, {flag: false, other: 3}, {flag: true, other: 4}, {flag: true, other: 5}, {flag: true, other: 6}, {flag: false, other: 7} ]; We are required to write a JavaScript function that takes in one such array and sorts it based on the following conditions: If arr.flag === false, the matching ...

Read More

Sorting an array objects by property having null value in JavaScript

Sakshi Jain
Sakshi Jain
Updated on 15-Mar-2026 3K+ Views

When sorting arrays of objects in JavaScript, null values can disrupt the natural sorting order. This article shows how to sort objects by a property while ensuring null values appear at the end of the sorted array. Understanding the Problem When sorting objects by a numeric property, null values need special handling because they don't follow normal comparison rules. Our goal is to sort by the property value while pushing null values to the end. The Solution Approach We'll use a custom comparator function with JavaScript's sort() method. The key insight is to treat null values ...

Read More

JavaScript - find distance between items on array

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 383 Views

In JavaScript, finding the distance between items in an array involves calculating the difference between each element and all succeeding elements. This creates a matrix of distances that can be useful for various algorithms and data analysis. Suppose we have a sorted (increasing order) array of Numbers like this: const arr = [2, 5, 7, 8, 9]; We need to write a JavaScript function that takes in one such array. The function should construct a new subarray for each element of the input array containing the differences between that element and all succeeding elements. ...

Read More

How to shift each letter in the given string N places down in the alphabet in JavaScript?

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

In the given problem statement our aim is to shift every letter in the given string N places down in the alphabet with the help of JavaScript functionalities. This is also known as the Caesar cipher technique. Understanding the Problem The problem at hand is to shift each character of the given string N places down in the alphabet using JavaScript. We need to take a string as input and update it by shifting every letter N positions down in the alphabet. For example, if the letter ...

Read More
Showing 14921–14930 of 61,297 articles
Advertisements