Articles on Trending Technologies

Technical articles with clear explanations and examples

Unique intersection of arrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 378 Views

We are required to write a JavaScript function that takes in two arrays of numbers, let's say arr1 and arr2. The function should find the intersection between the elements of the array. i.e., the elements that appear in both the arrays. The only condition is that if we encountered one element before as intersected, we should not consider it again even if appears again in both the arrays. For example − If the input arrays are − const arr1 = [1, 5, 7, 3, 1]; const arr2 = [1, 7, 3, 1, 6]; ...

Read More

Calculating a number from its factorial in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 238 Views

We are required to write a JavaScript function that takes in a number as the only argument. The function should check whether there exists any number whose factorial is the number taken as input. If there exists any such number, we should return that number otherwise we should return -1. Problem Understanding Given a number, we need to find if it's a factorial of some integer. For example, 720 is the factorial of 6 because 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720. If the input is: ...

Read More

Largest rectangle sum smaller than num in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 237 Views

We are required to write a JavaScript function that takes in a 2-D array of Numbers as the first argument and a target sum number as the second argument. Our function should find out that rectangle from the 2-D array which has the greatest sum among all rectangles in the array but just less than or equal to the target sum specified by the second argument to the function. Problem Statement Given a 2D matrix and a target number, find the largest rectangle sum that is smaller than or equal to the target. The function should return ...

Read More

Constructing a sentence based on array of words and punctuations using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 888 Views

We need to write a JavaScript function that takes an array of words and punctuations and constructs a proper sentence following specific spacing and punctuation rules. Problem Statement Our function should join array elements to construct a sentence based on the following rules: There must always be a space between words There must not be a space between a comma and the word on the left There must always be one and only one period at the end of a sentence Solution Here's how ...

Read More

How to set the style of controlling corners of Ellipse using FabricJS?

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

In this tutorial, we are going to learn how to set the style of controlling corners of 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. 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 color to it, changing its size etc. We can change the style by using the cornerStyle property. Syntax ...

Read More

How to flip a Triangle horizontally using FabricJS?

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

In this tutorial, we are going to learn how we can flip a Triangle object horizontally 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. We can flip a triangle object horizontally using the flipX property. Syntax new fabric.Triangle({ flipX: Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our ...

Read More

How to set the style of controlling corners of Textbox using FabricJS?

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

In this tutorial, we are going to learn how to set the style of controlling corners of 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. 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 change the style by using the cornerStyle ...

Read More

How to find text box height in IText using FabricJS?

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

In this tutorial, we are going to learn about how to find text box height in 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 ...

Read More

How to break JavaScript Code into several lines?

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

We can break JavaScript code into several lines to improve readability and maintainability. JavaScript provides several methods to split long statements across multiple lines without breaking the code's functionality. Methods to Break JavaScript Code Using Backslash (\) Line Continuation The backslash character at the end of a line tells JavaScript to continue reading the next line as part of the same statement: let longString = "This is a very long string that needs to be \ broken into several lines for better readability"; console.log(longString); This is a very long string that ...

Read More

How to filter out common array in array of arrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 315 Views

When working with arrays of arrays in JavaScript, you may need to remove duplicate subarrays and keep only unique ones. This is useful for data deduplication and filtering operations. The Problem Suppose we have an array of arrays with duplicate subarrays: const arr = [ [ "Serta", "Black Friday" ], [ "Serta", ...

Read More
Showing 15171–15180 of 61,297 articles
Advertisements