JS Array Methods Table

–click a method to copy it - 12 methods that cover 95% of array work
MethodReturnsWhat it does
map() newArrayTransforms every element using the callback
filter() newArrayKeeps elements where the callback returns true
reduce() single valueAccumulates elements into one value
find() element or undefinedFirst element matching the condition
findIndex() number or -1Index of first element matching the condition
some() booleanTrue if at least one element passes the test
every() booleanTrue if all elements pass the test
includes() booleanTrue if the array contains the value
sort() same array (mutates)Sorts in place - always pass a comparator for numbers
flat() newArrayFlattens nested arrays one level (or depth argument)
flatMap() newArraymap() then flat() in one pass
join() stringConcatenates all elements with a separator
Method semantics follow MDN's Array reference. The critical distinction: map, filter, flat, flatMap and slice return NEW arrays (original unchanged), while sort, splice, push, pop, shift and unshift MUTATE the original. sort() without a comparator converts elements to strings - sorting [10, 1, 5] gives [1, 10, 5] because "10" < "5" as strings. Bottom line: the functional trio map + filter + reduce replaces 90% of for loops - and because they return new arrays, they chain naturally: arr.filter(Boolean).map(String).sort(). Array hub: binary powers table, regex cheatsheet, SHA-256 hash, GCD and LCM calculator.

JavaScript arrays have 30+ methods, but twelve cover virtually all array work: map (transform each), filter (keep matching), reduce (accumulate to one value), find (first match), findIndex (position of first match), some (at least one passes), every (all pass), includes (contains), sort (order in place), flat (flatten nested), flatMap (map+flatten) and join (to string).

The mutation distinction is the most common source of bugs: sort() modifies the original array while map() and filter() return new ones. In modern JS, toSorted() gives you a sorted copy without mutation.

How to use

  1. Filter by method name or what it returns - new array, single value, mutates - to find the tool you need.
  2. Click any method to copy the name into your code or documentation.
  3. Read the returns column: it tells you whether the original array is preserved.

Frequently asked questions

Why does sort() sort numbers incorrectly by default?

sort() without a comparator converts elements to strings and compares them lexicographically: [10, 1, 5] becomes [1, 10, 5] because "10" sorts before "5" as strings. Always pass a comparator for numbers: arr.sort((a, b) => a - b) for ascending.

What is the difference between splice and slice?

splice() modifies the original array - it removes, replaces or inserts elements in place. slice() returns a new array without modifying the original. The one-letter difference between p and l (splice vs slice) is the difference between mutation and immutability.

When should I use flatMap instead of map + flat?

Use flatMap when your callback returns an array for each element and you want to flatten the result in one pass. It is equivalent to arr.map(fn).flat() but avoids creating an intermediate array. The classic use case: splitting sentences into words, or expanding one-to-many relationships.

Does reduce() have a use case beyond summing numbers?

Yes - reduce is the most powerful array method because it can implement map, filter, find, group by, count by, and any other transformation. It is the functional programming building block: everything else is a specialised version of reduce. But use the specialised methods first for readability.

Related tools