Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The reverse() method of Array instances reverses an array in place and returns the reference to the same array, the first array element now becoming the last, and the last array element becoming the first. In other words, elements order in the array will be turned towards the direction opposite to that previously stated.
To reverse the elements in an array without mutating the original array, use toReversed().
None.
The reference to the original array, now reversed. Note that the array is reversed in place, and no copy is made.
The reverse() method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.
The reverse() method preserves empty slots. If the source array is sparse, the empty slots' corresponding new indices are deleted and also become empty slots.
The reverse() method is generic. It only expects the this value to have a length property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable.
The following example creates an array items, containing three elements, then reverses the array. The call to reverse() returns a reference to the reversed array items.
The reverse() method returns reference to the original array, so mutating the returned array will mutate the original array as well.
In case you want reverse() to not mutate the original array, but return a shallow-copied array like other array methods (e.g., map()) do, use the toReversed() method. Alternatively, you can do a shallow copy before calling reverse(), using the spread syntax or Array.from().
Sparse arrays remain sparse after calling reverse(). Empty slots are copied over to their respective new indices as empty slots.
The reverse() method reads the length property of this. It then visits each property having an integer key between 0 and length / 2, and swaps the two corresponding indices on both ends, deleting any destination property for which the source property did not exist.
| ECMAScript® 2027 Language Specification # sec-array.prototype.reverse |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 20, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.