Articles on Trending Technologies

Technical articles with clear explanations and examples

How to add linethrough to Text using FabricJS?

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

In this tutorial, we are going to learn about how to add linethrough text decoration to 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, font family, line height which can be obtained by the properties textAlign, fontFamily and lineHeight respectively. We can add linethrough by using the linethrough property. Syntax new fabric.Text(text: String , { linethrough: Boolean }: Object) Parameters ...

Read More

How to create a JSON representation of a Line object using FabricJS?

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

In this tutorial, we are going to learn about how to create a JSON representation of a Line object 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 create a JSON representation of a Line object, we use the toJSON method. ...

Read More

How to add default horizontal scaling to a canvas-type text with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 400 Views

We can add default horizontal scaling to canvas text by using the scale() method on the 2D rendering context. This method transforms all subsequent drawing operations, including text, by scaling them horizontally and vertically. HTML Canvas HTML canvas is a 2D drawing surface that allows developers to create dynamic graphics, charts, and animations using JavaScript. The canvas element provides a powerful API for drawing shapes, text, and images directly in the browser. The canvas element acts as a container for graphics and can be manipulated using the Canvas API to create rich, interactive user experiences without external ...

Read More

How to create a function from a string in JavaScript?

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

Creating a function from a string in JavaScript can be helpful in situations when you need to generate a function dynamically at runtime or when you have a string that contains the code for a function you wish to execute. JavaScript provides several methods to create functions from strings, each with different security implications and use cases. The most common approaches are using eval(), the Function() constructor, and Function.prototype.constructor. Approach 1: Using the eval() Function The JavaScript eval() method is one of the easiest ways to build a function from a string. This powerful function can execute ...

Read More

Deleting the last vowel from a string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 284 Views

We are required to write a JavaScript function that takes in a string and returns a new string with the last vowel of each word removed. For example: If the string is − const str = 'This is an example string'; Then the output should be − const output = 'Ths s n exampl strng'; Therefore, let's write the code for this function − Example The code for this will be − const str = 'This is an example string'; const removeLast = word => { ...

Read More

Finding number plate based on registration number in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 691 Views

The car registering system of a city assigns unique identifiers to customers and corresponding number plates to their vehicles. We need to create a JavaScript function that converts a customer ID into its corresponding number plate format. Problem Statement The car registration system assigns two types of identifiers: Customer ID − A natural number between 0 and 17, 558, 423 (inclusive), assigned sequentially starting from 0 Number Plate − Contains a series ...

Read More

All right triangles with specified perimeter in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 185 Views

We are required to write a JavaScript function that takes in a number that specifies the perimeter for a triangle. Our function should return an array of all the right triangle side triplets whose perimeter matches the specified input. Understanding Right Triangles A right triangle satisfies the Pythagorean theorem: a² + b² = c², where c is the hypotenuse (longest side). For a given perimeter P, we need a + b + c = P. Algorithm Approach We use three nested loops to check all possible combinations of triangle sides. For each triplet, we verify: ...

Read More

Finding maximum length of common subarray in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 413 Views

Finding the maximum length of a common subarray (also known as the longest common subarray) is a classic dynamic programming problem. We need to find the longest contiguous sequence that appears in both arrays in the same order. Problem Statement We are required to write a JavaScript function that takes in two arrays of literals, arr1 and arr2, as the first and the second argument respectively. Our function should return the maximum length of a subarray that appears in both arrays. For example, if the input arrays are: const arr1 = [1, 2, 3, 2, ...

Read More

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
Showing 11701–11710 of 61,303 articles
Advertisements