DevMetrix
.
cloud
Home
Tools
Blog
Examples
System Designer
Cheat Sheets
Comparisons
Projects
About
Advertisement
← All Cheat Sheets
JavaScript Array Methods
Quick reference for JavaScript arrays
Iteration
arr.forEach(fn)
Iterate over each item
Copy
arr.map(fn)
New array with fn applied
Copy
arr.filter(fn)
Items where fn returns true
Copy
Searching
arr.find(fn)
First match
Copy
arr.indexOf(val)
First index or -1
Copy
arr.includes(val)
Contains value?
Copy
Transformation
arr.sort(fn)
Sort in place
Copy
arr.reverse()
Reverse array in place
Copy
arr.reduce(fn, init)
Reduce to single value
Copy
Extras
arr.concat(arr2)
Merge arrays
Copy
arr.join(sep)
Join array to string
Copy
[...arr]
Copy array
Copy
Advertisement