Replace or append a value in a JavaScript array
Quickly and easily replace or append a value in a JavaScript array.
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.
Quickly and easily replace or append a value in a JavaScript array.
Ever needed to convert a NodeList
to an array in JavaScript? Here's the fastest way to do so.
Sort an array of numbers, using the heapsort algorithm.
Calculate the ranking of an array based on a comparator function in JavaScript.
Sort an array of numbers, using the selection sort algorithm.
Sort an array of numbers, using the quicksort algorithm.
Sort an array of numbers, using the bucket sort algorithm.
Learn how to shuffle, sample and perform weighted selection on JavaScript arrays.
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.
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.
Ever wanted to use negative indices in JavaScript arrays? Here's a simple way to do it using a Proxy.
Converts the output of any generator function to an array using the spread operator.
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.
Learn how to split a JavaScript array into two groups based on a function or an array of values.
Learn how you can compare two arrays in JavaScript using various different techniques.
Given a value, find out how many times it appears in an array or string.
Which method do you reach for first? What are the differences between them? Let's find out!
Create an array of partial sums, using Array.prototype.reduce()
and Array.prototype.slice()
.
Sort an array of numbers, using the merge sort algorithm.