JavaScript: Get the user’s preferred language
Updated: Aug 05, 2023
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 Point? The navigator.language,......
JavaScript: Check if a Year is a Leap Year (2 Ways)
Updated: Aug 05, 2023
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 for years divisible by 100 unless they are divisible by 400. Some......
JavaScript: Convert a string to Unicode code points (2 ways)
Updated: Aug 05, 2023
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. Converting a string to Unicode code points......
JavaScript: Remove Multiple Consecutive White Spaces
Updated: Jun 17, 2023
When working with text data in JavaScript, there might be cases where you encounter a string that contains multiple consecutive whitespace characters like this: "Welcome to Sling Academy!" The string above look so weird, and......
JavaScript: Convert String to Hex and Vice Versa
Updated: Jun 17, 2023
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. A hex representation of a string is a way of encoding each character of the string as a hex value, usually......
JavaScript: Convert Null, NaN, Undefined, and False to Zero
Updated: Jun 17, 2023
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 or properties that can have these values, assigning them 0 as a default......
JavaScript: Check if a string contains non-alphanumeric characters
Updated: Jun 17, 2023
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 (., ?, :), and whitespace characters (space, tab). When developing web......
JavaScript: 2 Ways to Format a String with Leading Zeros
Updated: Jun 15, 2023
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 you through a......
JavaScript: Remove non-alphanumeric characters from a string
Updated: Jun 15, 2023
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 such as !, ?, and -. These characters are not part of......
JavaScript: Convert a String to Binary (2 Approaches)
Updated: Jun 14, 2023
Binary refers to the representation and manipulation of data using the base-2 number system, which uses only 0s and 1s. It is used for bitwise operations, handling binary data, and working with flags or binary flags in......
JavaScript: 3 Ways to Find the Product of a Numeric Array
Updated: May 25, 2023
The product of a numeric array is the result of multiplying all the numbers within the array together. For example, the product of the array [1, 2, 3] is 6, and the product of the array [2, 2] is 4. This succinct, example-based......
JavaScript: 3 Ways to Create Multiline Strings
Updated: May 25, 2023
This practical, example-based article shows you three different ways to declare a multiline string in JavaScript. Using template literals (ES6 and newer) The main points of this approach are: Use backticks (`) to define the......