JavaScript Array Methods

All Array prototype methods with signature, return type and mutability flag

Searchable JavaScript Array method reference. Each entry lists the call signature, return type, whether the method mutates the array in place or returns a new one, and the ECMAScript version that introduced it.

Which array methods mutate the original array?

The mutating methods are push, pop, shift, unshift, splice, sort, reverse, fill, and copyWithin. They change the array in place and usually return a length or the array itself rather than a fresh copy. Everything else returns a new array or a value.

The Array prototype has many methods, and the difference between one that mutates in place and one that returns a fresh array is a frequent source of bugs. This reference lists each method with its signature, return type, mutability, and the ECMAScript version that added it.

How it works

Each method is classified by what it does to the array:

  • Mutatingpush, pop, shift, unshift, splice, sort, reverse, fill, copyWithin change the array in place.
  • Non-mutatingmap, filter, slice, concat, flat, and the rest return a new array or a single value, leaving the original untouched.
  • Immutable copies (ES2023)toSorted, toReversed, toSpliced, and with are drop-in immutable versions of the mutating methods.

The reference tags each entry so you can see at a glance whether calling it is safe inside a pure function or a React render.

Tips

Inside React state updates and any functional pipeline, avoid the mutating methods on data you do not own — sort a copy with [...arr].sort() or use toSorted(). Remember reduce needs an initial value to be safe on possibly empty arrays, and that map/filter/forEach skip holes in sparse arrays. indexOf uses strict equality so it cannot find NaN; use includes, which does, when NaN matters.