Web Development Articles

Page 513 of 801

JavaScript tracking the differences between elements in an array

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

Tracking differences between elements in an array is a fundamental task in data analysis and software development. Whether you're analyzing trends in numerical data, measuring changes over time, or debugging an application's behavior, calculating these differences can provide valuable insights. In JavaScript, this task is often approached using various techniques, including loops and modern functional programming methods like the map() function. Here are two methods to calculate differences between elements in an array: Iterative Loop and Functional Programming using the map. Problem Statement We are given an array of Number literals, and we are required to write ...

Read More

JavaScript - Redirect a URL

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 778 Views

In JavaScript, redirecting a user from one URL to another is a straightforward task. There are multiple ways to achieve this, but we'll focus on two of the most common and effective methods: window.location.href and window.location.replace(). Both are widely used for different purposes, and understanding when to use each one can help improve user navigation on your site. Approaches to Redirect a URL in JavaScript Following are the different approaches to redirect a URL: Using window.location.href Using window.location.replace() Redirect a URL Using window.location.href Property The ...

Read More

JavaScript get row count of an HTML table

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 5K+ Views

Tables are a common way to organize and display data in HTML. If you're working with tables dynamically in JavaScript, you might need to count the rows in an HTML table for various purposes, such as validation, manipulation, or displaying statistics. In this article, we will demonstrate how to retrieve the row count of an HTML table using JavaScript. We will use the rows property to access the row count through rows.length, and also show how to count rows in specific table sections like . Understanding the rows Property The rows property in JavaScript provides access to ...

Read More

JavaScript remove random item from array and then remove it from array until array is empty

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 3K+ Views

We are given an array of string/number literals. We are required to create a function removeRandom() that takes in the array, recursively removes one random item from it, and simultaneously prints it until the array contains items. This can be done by creating a random number using Math.random(), removing the item at that index using Array.prototype.splice(), and printing it until the length of the array shrinks to 0. Approaches to Remove Random Items from Array Following are the different approaches to removing the random item from an array and then removing it from the array until the ...

Read More

JavaScript program to access browsing history

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 877 Views

In this article, we will learn to access browsing history using JavaScript. In web development, accessing a user's browsing history can improve user experience and provide personalized content. However, due to privacy concerns and security reasons, modern web browsers limit the amount of browsing history accessible via JavaScript. What is Browsing History? Browsing history refers to the list of web pages that a user has visited over a while. Browsers typically store this data locally, allowing users to navigate back and forth through the pages they've visited. The window.history Object In JavaScript, the window.history object allows ...

Read More

JavaScript Regex to remove text after a comma and the following word?

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 928 Views

When working with strings in JavaScript, you might encounter scenarios where you need to clean or format text by removing specific portions. A common task is to remove text after a comma and the following word. This can be achieved efficiently using JavaScript Regular Expressions (Regex). In this article, we'll show you how to do it step-by-step. Why Use Regex for Text Manipulation? Regex, short for Regular Expressions, is a powerful tool for pattern matching and text processing. It allows you to identify and manipulate text patterns with precision, making tasks like cleaning data or reformatting strings much ...

Read More

JavaScript merge multiple Boolean arrays with the OR || operator

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 700 Views

There are times when you need to merge multiple Boolean arrays into a single array in JavaScript. One common approach is to combine the corresponding elements from each array using the OR (||) operator. This operation returns true if at least one of the elements being compared is true; otherwise, it returns false. In this article, we'll learn how to merge multiple Boolean arrays into a single array using JavaScript, specifically by applying the OR operator on corresponding elements. Problem Definition We are given an array of arrays of Boolean values, like this: Input: const ...

Read More

JavaScript Submit textbox on pressing ENTER?

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 3K+ Views

In this article, we will learn to Submit a textbox by pressing ENTER in JavaScript. Submitting a textbox form by pressing the ENTER key is a common requirement in web development, enhancing the user experience by making interactions smoother and more intuitive. Why Enable Form Submission on ENTER Key Press? Allowing users to submit a form by pressing the ENTER key is an efficient way to enhance usability and reduce friction in the user interface. Whether you're building a search bar, login form, or any other type of text input, implementing this feature saves time and makes interactions ...

Read More

JavaScript map value to keys (reverse object mapping)

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 1K+ Views

In JavaScript, there are scenarios where we need to reverse the mapping of keys and values in an object, creating a new object where the original values become keys, and the keys become their corresponding values. For example, cities can be grouped by their states. In this article, we'll learn two approaches to achieve this: using Object.keys with iteration and reduce. Using Object.keys() with forEach The first approach involves iterating over the keys of the original object using Object.keys() of Object properties and populating a new object. If multiple keys in the original object share the same value, ...

Read More

How can I round a number to 1 decimal place in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 34K+ Views

In this tutorial, we will learn to round a number to a one decimal place in JavaScript. There are various needs to round the float numbers and show particular digits after the decimal point. In our case, we need to show only one digit after the decimal point. However, we will create a customizable function that can round off the number and show the particular number of digits after the decimal point at the end of this tutorial. This example lets users understand the fundamental need to round a number to a single decimal digit. Suppose you are ...

Read More
Showing 5121–5130 of 8,010 articles
« Prev 1 511 512 513 514 515 801 Next »
Advertisements