Advertisement
← All Cheat Sheets

JavaScript Array Methods

Quick reference for JavaScript arrays

Iteration

arr.forEach(fn)Iterate over each item
arr.map(fn)New array with fn applied
arr.filter(fn)Items where fn returns true

Searching

arr.find(fn)First match
arr.indexOf(val)First index or -1
arr.includes(val)Contains value?

Transformation

arr.sort(fn)Sort in place
arr.reverse()Reverse array in place
arr.reduce(fn, init)Reduce to single value

Extras

arr.concat(arr2)Merge arrays
arr.join(sep)Join array to string
[...arr]Copy array
Advertisement