Array.prototype.reverse()

Reverses an array in place and returns the same array.

Since ES1 Spec ↗

Syntax

arr.reverse()

Returns

Array — The reversed array (the same reference).

Examples

const a = [1, 2, 3];
console.log(a.reverse(), a);
Output
[ 3, 2, 1 ] [ 3, 2, 1 ]
console.log(['a', 'b'].reverse());
Output
[ 'b', 'a' ]

Notes

Mutates the array in place. Use `toReversed` (ES2023) or `[...a].reverse()` for a non-mutating copy.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also