Javascript Articles

Page 214 of 534

How to set the vertical scale factor of Textbox using FabricJS?

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

In this tutorial, we are going to learn how to set the vertical scale factor 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. Just as we can specify the position, colour, opacity and dimension of a textbox object in the canvas, we can also set the vertical scale factor of a textbox object. This can be done by using the scaleY property. Syntax new fabric.Textbox(text: ...

Read More

How to set the width of Textbox using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 951 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 create a chessboard pattern with JavaScript and DOM?

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

Creating visual patterns with JavaScript and DOM manipulation is a great way to understand programming logic. In this tutorial, we'll create a classic chessboard pattern using JavaScript to dynamically generate alternating colored squares. Algorithm Overview The chessboard pattern relies on a simple mathematical principle: if the sum of row and column indices is even, the square is one color (black), otherwise it's another color (white). This creates the alternating pattern characteristic of a chessboard. Basic Implementation Here's how to create a chessboard pattern step by step: Create a container div for the chessboard Use ...

Read More

How to Create Fullscreen API using JavaScript?

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

The Fullscreen API is a browser API that allows developers to request fullscreen display from the user, and to exit fullscreen when desired. Using the Fullscreen API is relatively simple. First, you must check if the browser you are using supports the Fullscreen API. You can do this by checking for the presence of the requestFullscreen method on any element. If the browser does not support the Fullscreen API, you can still provide a fullscreen experience to your users by using another method, such as opening a new browser window. The function that requests full screen display ...

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 negate a predicate function in JavaScript?

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

In JavaScript, a predicate function is a function that returns a Boolean value. In other words, it is a function that tests whether a certain condition is true or false. There are times when we need to negate a predicate function. That is, we need to return the opposite Boolean value. There are several ways to negate a predicate function in JavaScript. Using the ! operator (Logical NOT) The most common way to negate a predicate function is to use the ! operator. For example, consider the following predicate function − function isEven(num) ...

Read More

How to implement enqueue and dequeue using only two stacks in JavaScript?

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

In this tutorial, we'll implement a queue using only two stacks. This is a common data structure interview question that demonstrates understanding of both queues (FIFO - First In, First Out) and stacks (LIFO - Last In, First Out). Algorithm STEP 1 − We have two stacks: one for enqueuing (input) and one for dequeuing (output). STEP 2 − We enqueue by pushing onto the enqueue stack. STEP 3 − We dequeue by popping from the dequeue stack. STEP 4 − ...

Read More

How to create infix to postfix converter in JavaScript?

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

An infix to Postfix converter is a tool that converts an infix expression to a postfix expression. In this tutorial, we will build the infix to postfix converter using JavaScript. What is an infix expression? Infix expression is an expression in which the operators are between the operands. For example, the expression "3 + 4" is an infix expression. What is a postfix expression? A postfix expression is an expression in which the operators are after the operands. For example, the expression "3 4 +" is a postfix expression. How does the Infix to Postfix converter work? ...

Read More

What is Variable Shadowing in JavaScript?

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

In programming, shadowing occurs when a variable declared in a certain scope (e.g. a local variable) has the same name as a variable in an outer scope (e.g. a global variable). When this happens, the outer variable is said to be shadowed by the inner variable. In JavaScript, variables can be shadowed in both the global and function scope. Global variables can be shadowed by function-scoped variables, and function-scoped variables can be shadowed by block-scoped variables declared with the let or const keyword. Variable Shadowing in the Global Scope In the global scope, shadowing occurs when a ...

Read More

How to Generate Random Birthday Wishes using JavaScript?

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

In this tutorial, we will learn how to generate a random birthday wish using JavaScript. We will use the Math.random() method to generate a random number and select a birthday wish from an array of wishes. The Math.random() Method The Math.random() method is a built-in function in JavaScript that returns a random number between 0 (inclusive) and 1 (exclusive). console.log(Math.random()); // 0.6789234567 console.log(Math.random()); // 0.1234567890 0.6789234567 0.1234567890 Creating the Array of Birthday Wishes First, we'll create an array containing various birthday wishes: var wishes = [ ...

Read More
Showing 2131–2140 of 5,340 articles
« Prev 1 212 213 214 215 216 534 Next »
Advertisements