JavaScript (ES2026) reference · Array Methods
JavaScript Array toReversed() Method
Return a new array with the elements in reverse order, leaving the original unchanged.
JavaScript (ES2026) Since ES2023
Syntax
array.toReversed()
Return value
A new array.
Examples
const a = [1, 2, 3];
console.log(a.toReversed(), a);
Output
[ 3, 2, 1 ] [ 1, 2, 3 ]
const steps = ["mix", "bake", "serve"];
for (const s of steps.toReversed()) console.log(s);
Output
serve bake mix
Version history
| Version | Change |
|---|---|
| JavaScript ES2023 | Added |
Related
array.reverse()· Reverse the array in place and return it. Use toReversed() to get a reversed copy instead.array.toSorted()· Return a new sorted array, leaving the original unchanged. Takes the same compare function as sort().- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial