How can I extend a 3-digit color code to a 6-digit color code in JavaScript?
Learn how to convert a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
The JavaScript snippet 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.
Learn how to convert a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
Using the Proxy object, we can create dynamic getters and setters for objects in JavaScript.
Assign default values for all properties in an object that are undefined
.
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.
JavaScript doesn't have a built-in way to check if a value is blank, but it's easy to create one.
Which method do you reach for first? What are the differences between them? Let's find out!
Learn how to create a unit converter data structure in JavaScript that can convert between any compatible units.
Trailing commas are not without controversy. Here's why I think you should use them.
Create an array of partial sums, using Array.prototype.reduce()
and Array.prototype.slice()
.
Sort an array of numbers, using the merge sort algorithm.
Have you ever wanted to serialize an object but only include certain keys? Turns out JavaScript provides an easy way to do this!
Learn how to leverage Intl.ListFormat
to join an array into a string, with appropriate separators.
Learn how to check if a number is prime and how to generate prime numbers up to a given number in JavaScript.
Learn how to initialize a 2D array in JavaScript in a handful of different ways.
Group the elements of an array based on the given function, producing an object with the grouped values.
Learn how to retrieve and manipulate the styles of an HTML element easily and efficiently with JavaScript.
Learn how to add an event listener that is executed at most once.
Use JavaScript's Math.hypot()
to calculate the Euclidean distance between two points.
Easily create a debounced function that returns a promise.
Explore how you can apply mathematical set operations to JavaScript Set
objects and arrays.
Efficiently check if a numeric array is sorted in ascending or descending order in JavaScript.
A few tips and tricks to help you filter arrays in JavaScript more efficiently.
Wrap a string to a given number of characters using a string break character in JavaScript.