Visually improving a website using JavaScript?

Kalyan Mishra
Updated on 15-Mar-2026 23:19:00

656 Views

In this article, you will learn various techniques to make your website attractive and fast using JavaScript, which will increase user engagement and make your website more productive. What is JavaScript? JavaScript is a web development language used to add functionality and interactivity to websites. It makes websites dynamic, robust, faster, and more engaging. JavaScript is an interpreted scripting language that runs directly in web browsers without needing compilation, making it one of the most popular languages in modern software development. To develop a complete website, you need three fundamental technologies: HTML ... Read More

Compare and fill arrays - JavaScript

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

307 Views

We are required to write a function that compares two arrays and creates a third array filling that array with all the elements of the second array and filling null for all those elements that are present in the first array but misses out in the second array. For example − If the two arrays are − const arr1 = ['f', 'g', 'h']; const arr2 = ['f', 'h']; Then the output should be − const output = ['f', null, 'h']; Algorithm Approach The solution uses an offset variable to ... Read More

How can I get H1 innerText in JavaScript without the innerText of its child?

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

3K+ Views

Getting the inner text of an HTML element is a common task when developing web applications. In JavaScript, it can be done using the innerText property of the HTMLElement object. However, this only returns the text within that particular element and not any of its child elements. If you need to get just the H1 tag's innertext without including its child elements' innertext, then there are several ways to do so. This article will discuss some methods for getting an H1 tag's innertext in JavaScript without including its child elements' innertext. The rendered text content of a node, ... Read More

Trim and split string to form array in JavaScript

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

929 Views

When working with comma-separated strings that contain unwanted whitespace, you need to trim spaces and split the string into an array. JavaScript provides multiple approaches to accomplish this task efficiently. Problem Statement Given a comma-separated string with irregular spacing: const str = "a, b, c, d , e"; console.log("Original string:", str); Original string: a, b, c, d , e We need to remove all whitespaces and split it into a clean array of elements. Method 1: Manual Space Removal This approach manually loops through the string to remove spaces ... Read More

Min window substring in JavaScript

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

2K+ Views

We are required to write a JavaScript function that takes in two strings let's call them str1 and str2. The size of str1 is guaranteed to be greater than that of str2. We are required to find the smallest substring in str1 that contains all the characters contained in str2. For example − If the input strings are − const str1 = 'abcdefgh'; const str2 = 'gedcf'; Then the output should be − const output = 'cdefg'; because this the smallest consecutive substring of str1 that contains all characters ... Read More

Finding the nth power of array element present at nth index using JavaScript

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

393 Views

We need to write a JavaScript function that takes an array of numbers and maps each element to its power based on its 0-based index position. For example, the element at index 0 is raised to power 0, the element at index 1 is raised to power 1, and so on. Problem Statement Create a function that transforms an input array where each element is raised to the power of its index position, then return the resulting array. Example Here's how to implement this using a traditional for loop: const arr = [5, 2, ... Read More

send(), sendStatus() and json() method in Node.js

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

5K+ Views

In Express.js, the send(), sendStatus(), and json() methods are essential for sending responses to clients. The send() method sends data in string format, json() sends data in JSON format with proper headers, and sendStatus() sends HTTP status codes with default status messages. Prerequisites Node.js installed Basic understanding of Express.js Installation Install the Express module using npm: npm install express Understanding sendStatus() Method The sendStatus() method sends an HTTP status code along with its default message. Common status codes include 200 (OK), 404 (Not Found), 201 (Created), ... Read More

How to search a string for a pattern in JavaScript?

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

801 Views

Searching strings for specific patterns is a common task in JavaScript. Strings are data types and are represented as a sequence of characters. Searching patterns means verifying the presence of a specific pattern in a given string. A pattern would be a specific word, specific characters, and so on. JavaScript offers several powerful methods for pattern matching, such as inbuilt string methods and regular expressions. This article will guide you on how to search strings for specific patterns in JavaScript. Table of contents Searching strings for specific patterns in JavaScript can be done in the following ways: ... Read More

How to flip a Rectangle vertically using FabricJS?

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

339 Views

In this tutorial, we are going to learn how we can flip a Rectangle object vertically 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. We can flip a rectangle object vertically using the flipY property. Syntax new fabric.Rect({ flipY: Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our ... Read More

FabricJS – How to set a multiplier to scale by in the URL string of a Line object?

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

546 Views

In this tutorial, we are going to learn about how to set a multiplier to scale by in the URL string of 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 a multiplier to scale by in the URL ... Read More

Advertisements