Reverse an array in JavaScript
javascript
Updated August 29, 2026
Array.prototype.reverse() reverses an array in place and returns the same array:
const values = [1, 2, 3];
values.reverse();
console.log(values); // [3, 2, 1]
If the original array must stay unchanged, make a shallow copy first:
const original = [1, 2, 3];
const reversed = [...original].reverse();
In newer runtimes, original.toReversed() expresses the non-mutating version directly. Both approaches copy the array structure, not nested objects; changing a nested object can still affect the original. Sparse arrays and array-like values have their own behavior, so convert an iterable with Array.from() when needed.
Sources
related.
Ruslan Osipov
About the author