JavaScript (ES2026) reference · Array Methods
JavaScript Array reverse() Method
Reverse the array in place and return it. Use toReversed() to get a reversed copy instead.
JavaScript (ES2026) Since ES1
Syntax
array.reverse()
Return value
The same, reversed array.
Examples
const steps = [1, 2, 3];
steps.reverse();
console.log(steps);
Output
[ 3, 2, 1 ]
const original = [1, 2, 3];
const copy = original.toReversed(); // ES2023
console.log(original, copy);
Output
[ 1, 2, 3 ] [ 3, 2, 1 ]
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
In other languages
list.reverse()· Python
Related
array.toReversed()· Return a new array with the elements in reverse order, leaving the original unchanged.array.sort()· Sort the array in place and return it. Without a compare function elements are sorted as strings, so numbers need one.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial