Script/Reference/Global_Objects/Array/flatMap) , [ ` map() `
](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) , [ ` slice()
` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) , and [ `
splice() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
(to construct the array of removed elements that's returned).

The following methods always create new arrays with the ` Array ` base
constructor: [ ` toReversed() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed) , [ `
toSorted() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted) , [ `
toSpliced() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced) , and [ `
with() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/with) .

The following table lists the methods that mutate the original array, and the
corresponding non-mutating alternative:

Mutating method  |  Non-mutating alternative   
---|---  
[ ` copyWithin() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) |  No one-method alternative   
[ ` fill() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) |  No one-method alternative   
[ ` pop() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) |  [ ` slice(0, -1) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)  
[ ` push(v1, v2) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) |  [ ` concat([v1, v2]) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)  
[ ` reverse() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) |  [ ` toReversed() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed)  
[ ` shift() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) |  [ ` slice(1) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)  
[ ` sort() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) |  [ ` toSorted() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted)  
[ ` splice() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) |  [ ` toSpliced() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)  
[ ` unshift(v1, v2) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) |  [ ` toSpliced(0, 0, v1, v2) ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced)  
  
An easy way to change a mutating method into a non-mutating alternative is to
use the [ spread syntax ](/en-
US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) or [ ` slice() `
](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) to create a
copy first:

js

    
    
    arr.copyWithin(0, 1, 2); // mutates arr
    const arr2 = arr.slice().copyWithin(0, 1, 2); // does not mutate arr
    const arr3 = [...arr].copyWithin(0, 1, 2); // does not mutate arr
    

###  Iterative methods

Many array methods take a callback function as an argument. The callback
function is called sequentially and at most once for each element in the
array, and the return value of the callback function is used to determine the
return value of the method. They all share the same signature:

js

    
    
    method(callbackFn, thisArg)
    

Where ` callbackFn ` takes three arguments:

` element `

    

The current element being processed in the array.

` index `

    

The index of the current element being processed in the array.

` array `

    

The array that the method was called upon.

What ` callbackFn ` is expected to return depends on the array method that was
called.

The ` thisArg ` argument (defaults to ` undefined ` ) will be used as the `
this ` value when calling ` callbackFn ` . The ` this ` value ultimately
observable by ` callbackFn ` is determined according to [ the usual rules
](/en-US/docs/Web/JavaScript/Reference/Operators/this) : if ` callbackFn ` is
[ non-strict ](/en-
US/docs/Web/JavaScript/