References

Beginner-friendly references for web development, with live, editable examples.

The JavaScript array.toReversed() method

Method JavaScript All modern browsers Updated
Quick answer

The toReversed() method returns a new array with the elements in reverse order, leaving the original untouched — the non-mutating version of reverse(). [1, 2, 3].toReversed() returns [3, 2, 1] while the source stays [1, 2, 3].

Overview

toReversed() flips an array end-to-end and returns the result as a new array, without touching the original. It's the safe, non-mutating counterpart to reverse(), which reverses in place and is a frequent source of "why did my other variable change?" bugs.

Before this method existed, the idiom was [...arr].reverse() — copy, then reverse. toReversed() does that in one call and makes the intent explicit: you want a reversed copy, not a mutation. It's perfect for rendering a list newest-first without disturbing the source order.

It belongs to the same family of recent non-mutating methods as toSorted(), toSpliced() and with(), all of which return copies. They suit immutable state (React and friends) where mutating an array in place is exactly what you want to avoid. Support is solid in current browsers.

Syntax

const reversed = array.toReversed()

[1, 2, 3].toReversed()  // [3, 2, 1], original unchanged

Example

Live example
<pre id="out" style="font:15px ui-monospace,monospace"></pre>
<script>
  const order = ['first', 'second', 'third'];

  const newest = order.toReversed();

  document.getElementById('out').textContent =
    'newest first: ' + newest.join(', ') + '\n' +
    'original:     ' + order.join(', ');
</script>

Best practices

  • Use toReversed() when you need a reversed copy and must keep the original order.
  • Prefer it over [...arr].reverse() in modern code for clearer intent.
  • Use the mutating reverse() only when you mean to change the array in place.
  • Pair it with toSorted() for non-mutating sort-and-reverse pipelines.

Frequently asked questions

What is the difference between toReversed() and reverse()?
toReversed() returns a new reversed array; reverse() reverses the array in place (mutating it).
How do I reverse an array without changing it?
Use arr.toReversed(), or the older [...arr].reverse().
Is toReversed() supported everywhere?
Yes, in all current browsers. Use [...arr].reverse() as a fallback for older ones.
Does toReversed() work on strings?
No — it's an array method. To reverse a string, use str.split("").toReversed().join("") or [...str].reverse().join("").