Formatting relative time in JavaScript
Did you know JavaScript has a built-in way to format relative time? It's called Intl.RelativeTimeFormat
and it's awesome!
The JavaScript article collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.
Did you know JavaScript has a built-in way to format relative time? It's called Intl.RelativeTimeFormat
and it's awesome!
Learn how to join the segments of a URL and normalize the resulting URL using JavaScript.
Learn how to convert a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
Given a value, find out how many times it appears in an array or string.
A collection of regular expressions that can be used to solve common problems.
Wrap a string to a given number of characters using a string break character in JavaScript.
Create a generator function that finds all the indexes of a substring in a given string.
Learn how to replicate the behavior of Array.prototype.map()
for strings.
Quickly determine if a collection of values is empty in JavaScript.
Learn how to remove accents from a string in JavaScript, quickly and efficiently.
Implement the Levenshtein distance algorithm in JavaScript to calculate the difference between two strings.
Learn how to capitalize the first letter of a string in JavaScript using array destructuring and String.prototype.toUpperCase()
.
Use JavaScript to generate a random alphanumeric string of a specified length.
Check if a string is an anagram of another string, handling case-insensitivity and special characters.
Learn how to convert text into HTML-safe strings and vice versa using JavaScript.
Email address validation can be much trickier than it sounds. Here's why and my advice on how to approach this problem.
Quickly and easily check if a string is a yes/no answer to a boolean question in your CLI programs.
String splitting and truncation, both simple and locale-sensitive are possible in JavaScript. Learn how in this guide.
Get all the partial substrings of a string in JavaScript using generator functions.
Use a regular expression to check if a string contains only alpha or alphanumeric characters in JavaScript.
Get the time part of a Date object in the format HH:MM:SS.
Here's a quick tip on how to compare and sort arrays of strings, ignoring case and accents.
Regular expressions are a very useful tool. Save this cheatsheet for when you need to look up their syntax and speed up your development.
Want to know if a string is an absolute URL? This article will help you out.