JavaScript

How to Pass a Variable from HTML Page to Another (w/ JavaScript)

One way to pass a variable from one HTML page to another using JavaScript is to use the browser’s localStorage object. localStorage provides a way to store key-value pairs in the user’s web browser, so that they persist across different pages and sessions. Here’s an example of how you could use localStorage to pass a […]

How to Pass a Variable from HTML Page to Another (w/ JavaScript) Read More »

4 Ways to Check If a String Contains a Substring in JavaScript

The Short Answer There are several ways to check if a JavaScript string contains a substring. Here’s a short summary of the most notable ones. 1. string.indexOf() Use the indexOf() method. This method returns the index of the first occurrence of the substring in the string, or -1 if the substring is not found. For

4 Ways to Check If a String Contains a Substring in JavaScript Read More »

JavaScript How to Find Duplicates in Array (without Removing)

To find (and not delete) duplicates in a JavaScript array, you can use this function: Example use: Output: To learn how the above approach works, and what alternatives exist, please keep on reading. This guide shows you ways to find array duplicates and show them instead of deleting them. Besides, you will learn what performance

JavaScript How to Find Duplicates in Array (without Removing) Read More »