How to calculate date difference in JavaScript
Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript.
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 calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript.
The Caesar cipher is a simple substitution cipher, which can be easily implemented with a few lines of JavaScript code.
Sort an array of numbers, using the bucket sort algorithm.
Learn everything you need to know about promises and asynchronous JavaScript with this handy cheatsheet.
JavaScript arrow functions are a very useful tool to learn and master. Here's a complete introduction to everything you need to know.
Learn how to shuffle, sample and perform weighted selection on JavaScript arrays.
Learn how to trigger an event on an HTML element using JavaScript.
A simple trick to remove one or more attributes from an HTML element.
If you need to check if Caps Lock is on when the user is typing in the browser, JavaScript's got you covered.
JavaScript callbacks are especially tricky when you're not careful. Take a deeper dive into potential issues and how to avoid them.
When working with JavaScript arrays, you might need the minimum or maximum value. Here are a few quick and easy ways to do it.
Remove an element from an array if it's included in the array, or push it to the array if it isn't.
Easily convert an rgb()
color string to an array of values or an object with the values of each color.
A quick introduction to the JavaScript Proxy object and where it can be used.
Learn how to recursively nest objects linked to one another in a flat array.
Did you know you can define an iterator for any JavaScript value? This quick tip will show you how.
Map an object to an object array, using the provided mapping function.
Learn the differences between the three most commonly used iteration methods in JavaScript, that often confuse beginners and veterans alike.
Learn how to compact an array or object in JavaScript using the Boolean
function and recursion.
Learn how to merge two arrays of objects, while combining objects based on a specified key.
Learn everything you need to know about Big-O notation with this handy cheatsheet.
Convert all the keys of an object to upper or lower case.
Learn how to use regular expressions to replace the last occurrence of a pattern in a JavaScript string.
Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky.