Articles on Trending Technologies

Technical articles with clear explanations and examples

Difference between two strings JavaScript

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

We are given two strings, say s and t. String t is generated by random shuffling string s and then add one more letter at a random position. We are required to write a JavaScript function that takes both these strings and returns the letter that was added to t. For example − If the input strings are − const s = "abcd", t = "abcde"; Then the output should be − const output = "e"; because 'e' is the letter that was added. Method 1: Using XOR ...

Read More

Retrieve key and values from object in an array JavaScript

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

In JavaScript, extracting keys and values from objects within an array is a common task when processing data structures. This can be accomplished using built-in Object methods like Object.keys() and Object.values(). Understanding the Problem When working with arrays of objects, you often need to access both the property names (keys) and their corresponding values. JavaScript objects are collections of key-value pairs, and the Object class provides methods to extract this information efficiently. Using Object.keys() and Object.values() The Object.keys() method returns an array of property names, while Object.values() returns an array of property values from an object. ...

Read More

Decimal to binary conversion using recursion in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 525 Views

We are required to write a JavaScript function that takes in a number as the first and the only argument. The function should use recursion to construct a string representing the binary notation of that number. For example − f(4) = '100' f(1000) = '1111101000' f(8) = '1000' How Binary Conversion Works Binary conversion involves repeatedly dividing a number by 2 and collecting the remainders. The remainders, read in reverse order, form the binary representation. Decimal 4 to Binary 4 ÷ 2 ...

Read More

Find Equivalent Value and Frequency in Array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 148 Views

We are required to write a JavaScript function that takes in an array of integers as the only argument. The function should check whether there exists an integer in the array such that its frequency is same as its value. If there exists at least one such integer, we should return that integer otherwise we should return -1. For example − If the input array is − const arr = [3, 4, 3, 8, 4, 9, 7, 4, 2, 4]; Then the output should be − 4 The ...

Read More

Applying f(x) to each array element in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 218 Views

When working with arrays in JavaScript, you often need to apply mathematical functions to each element and return a sorted result. This article demonstrates how to apply a quadratic function f(x) = ax² + bx + c to array elements. Problem Statement Given a mathematical function: f(x) = ax² + bx + c Where a, b, and c are constants, we need to create a JavaScript function that: Takes a sorted array of integers as the first argument Takes constants a, b, and c as the next three arguments Applies f(x) to each ...

Read More

Returning array values that are not odd in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 210 Views

Problem We are required to write a JavaScript function that takes in an array of numbers. Our function should construct and return a new array that contains all the numbers of the input array that are not odd (i.e., even numbers). Example Following is the code − const arr = [5, 32, 67, 23, 55, 44, 23, 12]; const findNonOdd = (arr = []) => { const res = []; for(let i = 0; i < arr.length; i++){ ...

Read More

How to set the width of stroke of Ellipse using FabricJS?

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

In this tutorial, we are going to learn how to set the width of stroke of an 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 strokeWidth property allows us to specify the width of a stroke for an object. Syntax new fabric.Ellipse( { strokeWidth: Number }: Object) Parameters options (optional) − This parameter is an Object which ...

Read More

How to hide the controlling borders of a Triangle using FabricJS?

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

In this tutorial, we are going to learn how to hide the controlling borders 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. We can customize our controlling borders in many ways such as adding a specific colour to it, a dash pattern, etc. We can also eliminate the borders completely by using the hasBorders property. Syntax new fabric.Triangle({ hasBorders: Boolean }: Object) Parameters ...

Read More

How to set the width of Textbox using FabricJS?

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

In this tutorial, we are going to learn how to set the width of 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. However, one of the fundamental properties of textbox is width which specifies the horizontal width of the textbox. Syntax new fabric.Textbox(text: String, { width: Number }: Object) Parameters text − This parameter accepts a String which ...

Read More

How to get the current character font size in IText using FabricJS?

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

In this tutorial, we are going to learn about how to get the current character font size 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 ...

Read More
Showing 15191–15200 of 61,297 articles
Advertisements