Get the index of an array item in a JavaScript for...of loop
Did you know you can get the index of an array item in a JavaScript for...of loop? Learn how with this bite-sized tip.
Finding ways to improve and optimize your code takes a lot of time, research and energy. Level up your coding skills one step at a time with this collection of quick tips and tricks.
Did you know you can get the index of an array item in a JavaScript for...of loop? Learn how with this bite-sized tip.
Calculate the ranking of an array based on a comparator function in JavaScript.
Implement the Luhn Algorithm, used to validate a variety of identification numbers.
Did you know you can define an iterator for any JavaScript value? This quick tip will show you how.
Ever needed to convert a NodeList
to an array in JavaScript? Here's the fastest way to do so.
Quickly and easily replace or append a value in a JavaScript array.
Learn how to merge two arrays of objects, while combining objects based on a specified key.
Learn how to use regular expressions to replace the last occurrence of a pattern in a JavaScript string.
ESLint is a really useful tool, but sometimes it gets in the way. Learn how to refactor code to get rid of a common warning.
SDBM is a simple, non-cryptographic hash function that can hash strings into whole numbers. Here's a JavaScript implementation.
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 resolve promises one after another (sequentially) in JavaScript.
Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky.
Ever wanted to get the value of an HTML input element as a number? Learn an easy way to do it with this handy trick.
Efficiently check if a numeric array is sorted in ascending or descending order in JavaScript.
Learn how to change the lightness component of an hsl()
color string using JavaScript.
Easily create a debounced function that returns a promise.
Learn how to create a string with uppercase characters converted to lowercase and vice versa.
Learn how to convert a 3-digit RGB notated hexadecimal color-code to the 6-digit form.
Learn how to leverage Intl.ListFormat
to join an array into a string, with appropriate separators.
Create an array of partial sums, using Array.prototype.reduce()
and Array.prototype.slice()
.
A simple trick to remove one or more attributes from an HTML element.
Immutability is a fundamental concept you should be familiar with when learning functional programming.
Create a generator function that finds all the indexes of a substring in a given string.