Articles on Trending Technologies

Technical articles with clear explanations and examples

How to get the entire document HTML as a string in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

One of the most useful features of JavaScript is the ability to get an entire document's HTML as a string. This can be used for many purposes, such as obtaining data from a website or creating dynamic content on your own website. In this article, we'll go over how to get the entire document HTML as a string in JavaScript. To get the entire document HTML as a string, we use the innerHTML property combined with methods to access the document element. The innerHTML property allows us to read or write HTML content dynamically. It's commonly used in ...

Read More

Largest index difference with an increasing value in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 162 Views

We need to write a JavaScript function that finds the largest difference between two indices j - i where arr[i] ≤ arr[j]. This means we're looking for the maximum distance between two positions where the value at the later position is greater than or equal to the value at the earlier position. Problem Statement Given an array of numbers, find the maximum value of (j - i) such that arr[i] ≤ arr[j] and i < j. Example Let's implement a solution that checks all possible pairs: const arr = [1, 2, 3, 4]; ...

Read More

Calculating variance for an array of numbers in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Problem We need to write a JavaScript function that calculates the variance for an array of numbers. Variance measures how spread out the numbers are from their average (mean). The variance formula involves two steps: Mean (M) = (Sum of all numbers) / (Count of numbers) Variance (V) = (Sum of squared differences from mean) / (Count of numbers) Understanding Variance Variance tells us how much the numbers in our dataset differ from the average. A low variance means numbers are close to the mean, while high variance means they're spread out. ...

Read More

urlObject.auth() Method in Node.js

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

The auth property of a parsed URL object contains the username and password portion of a URL, also known as userInfo. The username and password are separated by a colon (:). Syntax urlObject.auth Parameters The auth property is read-only and does not require any input parameters. It returns the authentication credentials from the parsed URL. Example 1: Basic Authentication Create a file named auth.js and run it using node auth.js: // Importing the URL module const url = require('url'); var adr = 'https://username=hello:password=tutorialspoint@www.tutorialspoint.com/'; // Parsing the above URL ...

Read More

How to set the cursor to wait in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 3K+ Views

In this article, we are going to look at how to set the cursor to wait in JavaScript. The wait cursor provides visual feedback to users that a process is running and prevents them from accidentally triggering multiple actions. Setting the cursor to wait is essential for improving user experience during operations like form submissions, file uploads, or API calls. JavaScript allows us to dynamically control cursor appearance using the CSS cursor property. Common Use Cases Here are typical scenarios where the wait cursor is beneficial: Processing payments to prevent double submissions ...

Read More

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

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

In this tutorial, we are going to learn how to hide the controlling borders 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. We can customize our controlling borders in many ways such as adding a specific colour to it, a dash pattern, etc. However, we can also eliminate the borders completely by using the hasBorders property. Syntax new fabric.Rect({ hasBorders: Boolean }: Object) Parameters ...

Read More

FabricJS – How to set the position of a Line object with respect to origin?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we are going to learn about how to set position of Line object with respect to origin 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 position of Line object with respect to origin we use the ...

Read More

Role of JavaScript in Software Companies?

Kalyan Mishra
Kalyan Mishra
Updated on 15-Mar-2026 426 Views

In this article, you will learn about the importance and role of the JavaScript language in the software industry. Where do we use the language and how it helps in production in the software companies everything we will get to know. JavaScript is one of the web development languages used to add functionality to the website. It makes the website interactive, robust, faster, and prettier. It's a scripting, interpreted language that can be directly compiled in a web browser like C, or CPP; it doesn't need a compiler to compile. Basically, to develop a website we need three ...

Read More

How to set location and location.href using JavaScript?

Gungi Mahesh
Gungi Mahesh
Updated on 15-Mar-2026 4K+ Views

The window.location object in JavaScript provides methods to get and set the current page URL. You can redirect users to different pages using either location or location.href properties. The window.location object can be written without the window prefix. Common location properties include: location.href − Gets or sets the complete URL location.hostname − Gets the domain name location.protocol − Gets the protocol (http: or https:) location.pathname − Gets the path portion of the URL location.assign() − Loads a ...

Read More

Grouping array nested value while comparing 2 objects - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 465 Views

When working with complex nested objects, you often need to compare and group data from different states. This article demonstrates how to group array nested values while comparing two objects in JavaScript. Problem Statement Suppose we have a JSON object containing "before" and "after" states of device data: const input = { "before": { "device": [ { "id": "1234", "price": "10", ...

Read More
Showing 16131–16140 of 61,297 articles
Advertisements