Articles on Trending Technologies

Technical articles with clear explanations and examples

How to hide the controlling corners of a Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to hide the controlling corners of a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. The controlling corners of an object allow us to increase or decrease its scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing their size, ...

Read More

How to set the size of subscript with Text using FabricJS?

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

In this tutorial, we are going to learn how to set the size of subscript with Text 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 use the subscript property where we can specify its size. Syntax new fabric.Text(text: String , { subscript : {"size": Number, "baseline": Number}: ...

Read More

How to set the angle of a Line in FabricJS?

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

In this tutorial, we are going to learn about how to set the angle 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 set the angle of a line object we use the angle property. Syntax ...

Read More

How to disable right-clicking on a website using JavaScript?

Kalyan Mishra
Kalyan Mishra
Updated on 15-Mar-2026 22K+ Views

To disable right-clicking on a website using JavaScript, you can use the contextmenu event to cancel the default behavior of the right-click. The contextmenu event is a DOM event that is triggered when a user right-clicks on an element in a user interface. It is a type of mouse event, similar to the click event, but it is specific to right-clicks. In JavaScript, you can use the addEventListener method to attach a contextmenu event listener to an element. The event listener function will be called whenever the contextmenu event is triggered on the element. Here's an example ...

Read More

Sort array of objects by string property value - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 442 Views

Sorting an array of objects by a string property is a common task in JavaScript. The most efficient approach uses the built-in sort() method with localeCompare() for proper alphabetical ordering. Sample Data Let's work with this array of person objects: const people = [ { first_name: 'Lazslo', last_name: 'Jamf' }, { first_name: 'Pig', last_name: 'Bodine' }, { first_name: 'Pirate', last_name: 'Prentice' } ]; console.log("Original array:", people); Original array: [ { first_name: 'Lazslo', last_name: 'Jamf' }, { ...

Read More

JavaScript map() is not saving the new elements?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 221 Views

The map() method creates a new array with transformed elements but doesn't modify the original array. A common mistake is not assigning the returned value from map() to a variable. The Problem: Not Saving map() Results map() returns a new array, so you must capture its return value: let numbers = [1, 2, 3]; // Wrong: map() result is ignored numbers.map(x => x * 2); console.log(numbers); // Original array unchanged // Correct: assign the result let doubled = numbers.map(x => x * 2); console.log(doubled); // New array with transformed values [ ...

Read More

How to create a password generator - JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 943 Views

These days, password generators can be found all over the internet. Without a strong enough password, websites frequently won't let you establish an account. In this article, we'll learn how to create a password generator using JavaScript and the Math.random() method. Let's dive into creating a password generator step by step. We'll use Math.random() to generate cryptographically secure random passwords with customizable length and character sets. Understanding Math.random() The JavaScript Math.random() function returns a floating-point pseudo-random number between 0 (inclusive) and 1 (exclusive). We can scale this random number to select characters from our password character set. ...

Read More

Finding the longest word in a string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 535 Views

We are required to write a JavaScript function that takes in a string as the only argument. The function should then iterate through the string and find and return the longest word from the string. For example − If the input string is − const str = 'Coding in JavaScript is really fun'; Then the output string should be − const output = 'JavaScript'; Using Array.reduce() Method The most efficient approach uses the reduce() method to iterate through words and track the longest one: const str = ...

Read More

Calculating and adding the parity bit to a binary using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 857 Views

A parity bit, or check bit, is a bit added to a string of bits to ensure that the total number of 1-bits in the string is even or odd. This is commonly used in error detection and data transmission. Problem Statement We need to write a JavaScript function that takes two parameters: the desired parity (either 'even' or 'odd') and a binary string representation. The function should return the parity bit (0 or 1) that needs to be added to achieve the specified parity. How Parity Bits Work Even Parity Example: ...

Read More

Stream writable.writableLength Property in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 335 Views

The writable.writableLength property returns the number of bytes (or objects) in the queue waiting to be written. This property is useful for monitoring buffer status and understanding the backpressure in your writable streams. Syntax writable.writableLength How It Works The property counts data that is: Buffered in the internal queue Waiting to be processed by the _write() method Corked (temporarily held) in memory Data that has already been written or is currently being processed is not counted. Example 1: Basic Usage with Cork Create a file named writableLength.js and run ...

Read More
Showing 16151–16160 of 61,299 articles
Advertisements