Use arr.reverse() to reverse an array in place. To get the reversed order without changing the original array, use arr.toReversed() where the runtime supports it, or reverse a shallow copy with [...arr].reverse().
Reverse an array in place with reverse()
reverse() changes the array it is called on and returns that same array reference:
As an Amazon Associate I earn from qualifying purchases.
const values = [1, 2, 3];
const result = values.reverse();
console.log(values); // [3, 2, 1]
console.log(result === values); // true
Because it mutates the original, any other variable referring to values sees the reversed order too. Assigning the return value to a new variable does not preserve the old array.
Keep the original order
Use toReversed() when supported
toReversed() returns a new array in reverse order and leaves the input array’s order unchanged:
#1 Best Overall
const values = [1, 2, 3];
const reversed = values.toReversed();
console.log(reversed); // [3, 2, 1]
console.log(values); // [1, 2, 3]
TypeScript includes the method’s declaration in its ES2023 library APIs. The lib option controls which built-in declarations the compiler recognizes, but declarations do not add a method to the JavaScript runtime. Check both your TypeScript configuration and the runtime where the code will execute; a successful type check alone does not guarantee that toReversed() exists there. See the TypeScript TSConfig lib reference and MDN’s toReversed() documentation.
Copy first for broader runtime compatibility
Make a shallow copy, then reverse that copy:
const values = [1, 2, 3];
const reversed = [...values].reverse();
// Alternative: values.slice().reverse()
The spread and slice() forms leave the original array’s order intact. Choose the expression that matches your mutation needs: reverse() for an in-place change, and toReversed() or copy-then-reverse for a separate result.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Readonly arrays and shallow copies
A value typed as readonly T[] cannot be mutated through that readonly type, so calling reverse() on it is not allowed by TypeScript. Copy it first to get a mutable array, for example with [...items].reverse(). toReversed() is also non-mutating when its declaration and runtime support are available. TypeScript describes ReadonlyArray as a type for arrays that should not be changed in its Object Types handbook.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThese copy-based approaches make a new outer array, not a deep copy of its elements. If the array contains objects, the original and reversed arrays still refer to the same objects. MDN explains this in its Array reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How sparse arrays behave
If an array contains empty slots, the methods handle them differently: reverse() preserves empty slots in their reversed positions, while toReversed() reads those holes as undefined and returns a dense array at those positions. For ordinary dense arrays of primitives, both approaches produce the expected reversed order. More detail is available in the MDN references for reverse() and toReversed().
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




