</> ConvertAtlas Developer Tools
Patterns

JavaScript Array Methods Cheatsheet

The array methods you use constantly in JavaScript. A key distinction runs through them: some return a new array (safe), others mutate the original in place.

Transforming (return new array)

Transform every element into a new array.
Keep elements that pass a test.
Map then flatten one level.
Copy a section without mutating.
Join arrays into a new one.

Reducing & searching

Collapse to a single value.
First element matching a test.
Index of the first match, or -1.
True if any element passes.
True if all elements pass.
True if the value is present.

Mutating (change original)

Add / remove at the end.
Add / remove at the start.
Remove or insert at an index.
Sort in place (pass a comparator!).
Reverse in place.

Iterating & joining

Run a function for each element.
Combine into a string.
Build an array from anything iterable.
Spread to merge or copy arrays.