Array.prototype.toReversed()
toReversed() Returns:
array · Added in vES2023 · Updated March 15, 2026 · Array Methods array reverse immutable
The toReversed() method returns a new array with the elements in reversed order. Unlike the older reverse() method which mutates the original array, toReversed() leaves your original data intact — a crucial distinction when working with React state, Redux, or any immutability-required codebase.
Syntax
arr.toReversed()
Examples
Basic usage
const arr = [1, 2, 3];
const reversed = arr.toReversed();
console.log(arr); // [1, 2, 3] (unchanged)
console.log(reversed); // [3, 2, 1]
Working with strings
const chars = ["a", "b", "c"];
const reversed = chars.toReversed();
console.log(reversed); // ["c", "b", "a"]
Preserving original with objects
const todos = [
{ id: 1, text: "Buy milk" },
{ id: 2, text: "Walk dog" },
{ id: 3, text: "Write code" }
];
const reversedTodos = todos.toReversed();
console.log(todos.length); // 3 (unchanged)
console.log(reversedTodos[0].text); // "Write code"
Sorting then reversing
const scores = [95, 42, 87, 73, 60];
const sorted = scores.toSorted((a, b) => a - b);
const reversed = sorted.toReversed();
console.log(sorted); // [42, 60, 73, 87, 95]
console.log(reversed); // [95, 87, 73, 60, 42]
Practical: displaying newest first
const posts = [
{ title: "Post 1", date: "2024-01-01" },
{ title: "Post 2", date: "2024-02-01" },
{ title: "Post 3", date: "2024-03-01" }
];
// Show newest posts at the top
const newestFirst = posts.toSorted((a, b) =>
new Date(b.date) - new Date(a.date)
);
console.log(newestFirst.map(p => p.title));
// ["Post 3", "Post 2", "Post 1"]
When to Use toReversed()
Choose toReversed() over reverse() when:
- You need to preserve the original array
- Working with React state or any immutable patterns
- Chaining array methods
- You want cleaner, more predictable code
See Also
Array.prototype.toSorted()— Return a sorted copy of an arrayArray.prototype.with()— Return a copy with element at index replaced