JavaScript Array.prototype.toReversed() Method
The toReversed() method returns a reversed copy of an array, leaving the original unchanged.
Description
The toReversed() method is the copying version of reverse(): it returns a new array in reverse order and leaves the original alone. Empty slots become undefined.
It was added in 2023 together with toSorted(), toSpliced() and with(), a group known as "change array by copy" methods. Before these, the usual way was [...arr].reverse() or arr.slice().reverse(), which work the same way but read less clearly.
The copy is shallow: if the array contains objects, the new array holds references to the same objects. Typed arrays have their own toReversed() method. Use it in code where data shouldn't be mutated, such as state in React or other UI frameworks, so components notice the change.
Syntax
array.toReversed()Return Value
A new array with the elements in reverse order.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.toReversed() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





