JavaScript Array.with() method (with examples)
This concise, straightforward article is dedicated to the Array.with() method in modern JavaScript. Overview The Array.with() method was added to the programming language in ECMAScript 2021, which is…
JavaScript: Get the user’s preferred language
This concise, straightforward article shows you how to detect the user’s preferred language in their web browser by using the built-in features of modern JavaScript. What is the…
JavaScript: Check if a Year is a Leap Year (2 Ways)
Leap years are years with an extra day, February 29, to keep the calendar year synchronized with Earth’s orbit around the sun. They occur every four years, except…
JavaScript: Convert a string to Unicode code points (2 ways)
Unicode code points are the numerical values that represent each character in the Unicode standard, which covers over a million characters from various languages, scripts, symbols, and emojis….
JavaScript: Remove Multiple Consecutive White Spaces
When working with text data in JavaScript, there might be cases where you encounter a string that contains multiple consecutive whitespace characters like this: The string above look…
JavaScript: Convert String to Hex and Vice Versa
A hex value (or a hexadecimal value) is a number that is represented in base 16, using digits from 0 to 9 and letters from A to F….
JavaScript: Convert Null, NaN, Undefined, and False to Zero
When developing web applications, there might be cases you want to treat falsy values like null, NaN, undefined, and false as 0 (for instance, If you have variables…
JavaScript: Check if a string contains non-alphanumeric characters
Non-alphanumeric characters refer to any character that is not a letter (A-Z, a-z) or a digit (0-9). Examples include symbols (!, @, #), punctuation marks (., ?, :),…
JavaScript: 2 Ways to Format a String with Leading Zeros
Padding strings with leading zeros ensures consistent formatting, proper sorting, and adherence to fixed-length requirements in numeric fields, data storage, and user interfaces. This pithy, example-based article walks…
JavaScript: Remove non-alphanumeric characters from a string
Non-alphanumeric characters in JavaScript are symbols and special characters that are not letters (a-z) or numbers (0-9). They include characters like @, #, $, %, and punctuation marks…