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

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

253 Views

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

How to create Expanding Cards using HTML, CSS, and JavaScript

Imran Alam
Updated on 15-Mar-2026 23:19:00

3K+ Views

In this tutorial, we will learn how to create Expanding Cards using HTML, CSS and JavaScript. Expanding cards provide an interactive way to display content with smooth animations and enhanced user experience. What are Expanding Cards? Expanding cards are interactive UI elements that scale up or reveal additional content when clicked. They are commonly used to display information in a compact format while providing an engaging way to access more details on demand. HTML Structure To create expanding cards, we need the following HTML elements: Card container element: Contains all cards ... Read More

Implement Green Screen Algorithm using JavaScript

Manisha Patil
Updated on 15-Mar-2026 23:19:00

1K+ Views

The green screen algorithm, also known as the chromakey algorithm, replaces all green pixels in a foreground image with corresponding pixels from a background image. This technique is widely used in film and video production to composite subjects against different backgrounds. The algorithm works by analyzing each pixel's color values. When a pixel has more green than red and blue combined, it's considered part of the green screen and gets replaced with the corresponding pixel from the background image. Requirements This implementation uses the SimpleImage library for image manipulation. Include this script in your HTML: ... Read More

Return correct value from recursive indexOf in JavaScript?

Yaswanth Varma
Updated on 15-Mar-2026 23:19:00

459 Views

A computer pattern or idea called recursion is present in many programming languages, including JavaScript. It is a feature used to build a function that repeatedly calls itself, but with a smaller input each time, until the intended outcome of the code is realized. In this article, we will return the correct value from a recursive indexOf() function in JavaScript. Let's dive into the article for a better understanding. Understanding Recursive indexOf Implementation The position of the first occurrence of a value in a string or array is returned by the indexOf() method. -1 is returned by ... Read More

Delete all text up to a character in a URL- JavaScript?

Yaswanth Varma
Updated on 15-Mar-2026 23:19:00

1K+ Views

This article explains how to use JavaScript's replace() method with regular expressions to delete all text up to a specific character in a URL. This technique is useful for extracting filenames, removing domain information, or cleaning URL strings. A regular expression (RegExp) is a pattern used to match character combinations in strings. In JavaScript, regular expressions are objects with properties and methods for pattern matching and text manipulation. The replace() Method The replace() method searches for a value or regular expression pattern in a string and returns a new string with the matched content replaced. The original ... Read More

Return indexes of greatest values in an array in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

479 Views

We are required to write a JavaScript function that takes in an array of Numbers. The array may contain more than one greatest element (i.e., repeating greatest element). We are required to write a JavaScript function that takes in one such array and returns all the indices of the greatest element. Using Array.reduce() Method This approach first finds the maximum value using Math.max(), then uses reduce() to collect all indices where the element equals the maximum value. const arr = [10, 5, 4, 10, 5, 10, 6]; const findGreatestIndices = arr => { ... Read More

Finding confusing number within an array in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

337 Views

A number in an array is confusing if it becomes another number which is also present in the array after we rotate it by 180 degrees. When rotated, digits transform as follows: 0→0, 1→1, 6→9, 8→8, 9→6. Other digits (2, 3, 4, 5, 7) cannot be rotated to form valid numbers. Understanding Confusing Numbers For a number to be confusing: It must contain only the digits 0, 1, 6, 8, 9 When rotated 180 degrees, it must form a valid number within our range The rotated number must also be present in the array Example ... Read More

Applying a custom function to each corresponding element of two arrays using JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

245 Views

We need to write a JavaScript function that applies a custom callback function to corresponding elements of two arrays, creating a new array with the results. Problem We are required to write a JavaScript function that takes in a callback function (which takes in two arguments and returns a value) as the first argument and two arrays of essentially the same length as the second and third argument. Our function should construct and return a new array whose each corresponding element is the return value of the callback function if corresponding numbers of the input array are ... Read More

cipher.update() Method in Node.js

Mayank Agarwal
Updated on 15-Mar-2026 23:19:00

730 Views

The cipher.update() method is used to update the cipher with data according to the specified encoding format. It is one of the built-in methods provided by the Cipher class within the crypto module. If an input encoding is specified, the data argument is a string; otherwise, the data argument is a buffer. Syntax cipher.update(data, [inputEncoding], [outputEncoding]) Parameters The parameters are described as follows: data – The data to be encrypted. Can be a string or buffer. ... Read More

How to load data from a server in React Native?

Shilpa S
Updated on 15-Mar-2026 23:19:00

1K+ Views

To load data from the server you can make use of the fetch API that is similar to XMLHttpRequest or any other networking APIs. It is very easy to make a request to the server using fetch. Take a look at the following code: fetch('https://jsonplaceholder.typicode.com/posts/1') .then((response) => response.json()) .then((responseJson) => console.log(responseJson)); In above code we are fetching the JSON file https://jsonplaceholder.typicode.com/posts/1 and printing the data to the console. The simplest call to fetch() API takes in one argument i.e the path you want to fetch and it returns a promise with ... Read More

Advertisements