JavaScript: Get the Position (X & Y Coordinates) of an Element
Updated: Apr 05, 2023
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 element? When you want to get the position of an element in......
JavaScript: Programmatically open a URL in a new tab/window
Updated: Mar 31, 2023
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 URL needs to be passed as the first argument, and _blank needs to be passed as the......
JavaScript: Show a Custom Context Menu on Right Click
Updated: Mar 31, 2023
What is the point? When developing websites and web apps with JavaScript, there might be cases where you want to show a custom context menu on right-click rather than the default context menu provided by browsers (which has a......
JavaScript: Define a Function with Default Parameters
Updated: Mar 30, 2023
Introduction In JavaScript, you can assign a default value to a function parameter so that it will be used if no value or undefined is passed as an argument. This can be useful for avoiding errors or providing sensible defaults for......
Using HTML Native Date Picker with JavaScript
Updated: Mar 30, 2023
The HTML native date picker is an input element with type=“date” that allows the user to enter a date, either with a textbox or a special date picker interface. It is supported by all major modern browsers, including Chrome, Microsoft......
JavaScript BigInt: Tutorial & Examples
Updated: Mar 29, 2023
Overview BigInt is a new data type in JavaScript that allows you to work with very large integers (greater than 2^53 – 1 or lower than -2^53 + 1 ) without losing precision. It has been supported by most web browsers since 2020......
How to Generate Random Colors in JavaScript (4 Approaches)
Updated: Mar 24, 2023
Introduction When developing modern websites and web apps with JavaScript, there could be instances where you need to generate random colors, such as: You want to reduce boredom and increase the freshness of your websites To......
JavaScript: Get filename & file extension from a URL
Updated: Mar 23, 2023
This short and straightforward article will walk you through a couple of different ways to extract the name and the extension from a URL of a file. All of these approaches will only use vanilla JavaScript. No third-party libraries are......
JavaScript Self-Invoking Functions: Tutorial & Examples
Updated: Mar 23, 2023
Overview JavaScript self-invoking functions (aka. Immediately invoked functions or IIFEs) are functions that run as soon as they are defined. They are useful when you need to create a function that will only be used once or to......
JavaScript: How to Programmatically Update Page Title
Updated: Mar 23, 2023
This concise, example-based article will show you how to programmatically update the title of a webpage by using pure JavaScript. Overview Before you start coding, let’s look at some possible (and elegant)......
JavaScript BOM (Browser Object Model) Cheat Sheet
Updated: Mar 23, 2023
This page provides a concise and comprehensive cheat sheet about BOM (Browser Object Model) in modern JavaScript (ES6 and newer). You can bookmark it for quick lookups in the future. Window object The Window object represents the......
How to iterate over a Map object in JavaScript
Updated: Mar 22, 2023
In JavaScript, iterating over a Map object can be useful for many tasks that involve accessing, modifying, or manipulating the key-value pairs. This practical, code-centric article will walk you through a couple of different ways to do so......