Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the dash pattern of controlling corners of Triangle using FabricJS?

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

In this tutorial, we are going to learn how we can implement the dash pattern of controlling corners of Triangle using FabricJS. The controlling corners of an object allow us to scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing its size, etc. We can also specify a dash pattern for the controlling corners by using the cornerDashArray property. Syntax new fabric.Triangle({ cornerDashArray: Array }: Object) Parameters ...

Read More

How to replace characters except last with a mask character in JavaScript?

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

JavaScript provides the replace() method to modify strings by replacing specific characters or patterns. A common requirement is to mask all characters in a string except the last one, which is useful for hiding sensitive data like credit card numbers or passwords. Syntax To replace all characters except the last one with a mask character, use this regex pattern: str.replace(/.(?=.)/g, maskCharacter); The regex /.(?=.)/g matches any character (.) that has at least one character after it ((?=.)), effectively selecting all characters except the last one. How It Works ...

Read More

How to add space between characters in Text using FabricJS?

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

In this tutorial, we are going to learn about how to add space between characters in a Text object 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 extra space between each character by using the charSpacing property. Syntax new fabric.Text(text: String , { charSpacing: Number }: ...

Read More

How to create a Line with dash pattern border using FabricJS?

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

In this tutorial, we are going to learn about how to create a Line with a dash pattern border using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the x and y coordinates of the line and adding it to the canvas. In order to change the appearance of the dashes of border we use the borderDashArray property. ...

Read More

How to create a global Promise Rejection Handler in JavaScript?

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

Promise rejection handlers are a powerful tool in JavaScript for handling errors that occur in asynchronous code. In this article, we will learn how to build a global promise rejection handler in JavaScript and how it can help your application manage errors effectively. You can detect unhandled promise rejections using the global unhandledrejection event and take necessary action, such as logging errors to an error tracking service or displaying user notifications. A more understandable syntax for handling promise rejection is provided by async-await error handling, but it requires wrapping each async function in a try-catch block. Combining async-await with ...

Read More

Dynamic programming to check dynamic behavior of an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 599 Views

We are required to write a JavaScript function that takes in an array of strings, ordered by ascending length. The function should return true if, for each pair of consecutive strings, the second string can be formed from the first by adding a single letter either at the beginning or end. For example: If the array is given by − const arr = ["c", "ca", "can", "acan", "acane", "dacane"]; Then our function should return true because: "ca" = "c" + "a" (adding "a" at the end) ...

Read More

Merge and group object properties in JavaScript

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

In JavaScript, merging and grouping object properties is a common task when working with arrays of objects. This technique allows you to combine objects that share a common property (like a name or ID) into single objects with all their properties merged. Understanding the Problem We need to create a JavaScript function that takes an array of objects and groups them by a common property (like 'name'), merging all properties of objects that share the same value for that property. Input: [ {name: 'Adi', age: 22, color:'Black'}, {name: 'Adi', weight: 40, height: ...

Read More

Finding sum of all numbers within a range in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 802 Views

Problem We are required to write a JavaScript function that takes in an array that specifies a range. Our function should find and return the sum of all the natural numbers falling in the range including the range numbers. Example Following is the code − const range = [4, 67]; const findSum = ([l, h]) => { let sum = 0; for(let i = l; i { // Formula: Sum = n * (first + last) / 2 // where ...

Read More

Return the nearest greater integer of the decimal number it is being called on in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 291 Views

The Math.ceil() function returns the smallest integer greater than or equal to a given number. This means it "rounds up" to the nearest integer. Syntax Math.ceil(x) Parameters x: A number to round up to the nearest integer. Return Value Returns the smallest integer greater than or equal to the given number. If the input is not a number, returns NaN. Example: Basic Usage console.log(Math.ceil(4.3)); // 5 console.log(Math.ceil(4.8)); // 5 console.log(Math.ceil(5.0)); // 5 (already integer) console.log(Math.ceil(-2.3)); // -2 console.log(Math.ceil(-2.8)); // -2 ...

Read More

Product of subarray just less than target in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 183 Views

We are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument, and a number, target, as the second argument. Our function is supposed to count and return the number of (contiguous) subarrays where the product of all the elements in the subarray is less than target. Problem Example For example, if the input to the function is: const arr = [10, 5, 2, 6]; const target = 100; The expected output is: 8 The 8 subarrays that have product less ...

Read More
Showing 11931–11940 of 61,303 articles
Advertisements