JavaScript

JavaScript: 4 Ways to Convert an Object to a Map

This practical, example-based article will walk you through a couple of different ways to convert an object into a map in modern JavaScript (ES6 and beyond). I assume…

Working with WeakSet in Modern JavaScript

What is a WeakSet In modern JavaScript (ES6 and beyond), a WeakSet is a collection of garbage-collectible values, including objects and non-registered symbols. Garbage-collectible values are values that…

Working with WeakMap in Modern JavaScript

Overview What is a WeakMap? A WeakMap is a collection of key/value pairs whose keys must be objects, with values of any arbitrary JavaScript type, and which does…

Let, Const, and Var in Modern JavaScript

let, const, and var are all keywords for declaring variables in JavaScript, but they have different scoping, hoisting, and reassignment behaviors. In general, with ES6 and beyond, it…

JavaScript: Convert an Object to a Query String and Vice Versa

Overview What is a query string? In the world of JavaScript and web development, a query string is a set of characters tacked onto the end of a…

Working with Sets in Modern JavaScript

What are Sets? Sets are a type of object in JavaScript that let you store unique values of any type, whether primitive values or object references. You can…

JavaScript: How to randomly change background color

Overview In this article, we will create a sample webpage whose background color is randomly changed when a button gets clicked or when the page is refreshed. We…

JavaScript: “I agree to terms” checkbox example

In most websites and apps, there is an “I agree to terms and conditions” checkbox (the phrase in the quotes may differ slightly) at the registration screen. This…

JavaScript: Get the Position (X & Y Coordinates) of an Element

This straightforward, practical article shows you how to determine the position (X and Y coordinates) of an element by using vanilla JavaScript. What is the position of an…

JavaScript: Programmatically open a URL in a new tab/window

What is the point? Open a URL in a new tab In JavaScript, you can programmatically open a URL in a tab by using the window.open() method. The…

1 2 3 4 5 15