JavaScript Array Methods - Cheat Sheet
1. Callback-Based Methods
Methods that Accept Callback:
- forEach(): Runs a function on each element (no return).
- map(): Returns a new array after applying a function to each element.
- filter(): Returns elements that pass a test.
- find(): Returns the first element that passes a test.
- findIndex(): Returns index of first element that passes a test.
- some(): Returns true if at least one element passes a test.
- every(): Returns true if all elements pass a test.
- reduce(): Reduces array to a single value (left-to-right).
- reduceRight(): Like reduce, but right-to-left.
- flatMap(): Maps and flattens array one level.
- sort(): Sorts array (can use custom comparator).
2. Non-Callback Methods
Methods that Do Not Accept Callback:
- push(), pop(), shift(), unshift(), splice(): Modify array content.
- slice(), concat(), flat(): Return a new array (non-mutating).
- reverse(), fill(), copyWithin(): Modify original array.
- join(), toString(), includes(), indexOf(), lastIndexOf(), at(): Do not mutate.
3. Quick Summary
Summary Table:
Feature | Methods
------------------|----------------------------------------------------------
Page 1 - Generated on 2025-05-13
JavaScript Array Methods - Cheat Sheet
Uses callback | forEach, map, filter, find, reduce, etc.
No callback | push, pop, splice, slice, flat, at, join, etc.
Returns new array | map, filter, slice, flat, concat, flatMap
Mutates array | push, pop, splice, sort, reverse, fill, etc.
Page 2 - Generated on 2025-05-13