Suggest an editImprove this articleRefine the answer for “What does toReversed() do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`toReversed()`** is a new, safe counterpart to the older `reverse()` method, added in the ECMAScript 2023 (ES14) standard: it returns a new array with the elements in reverse order without changing the original array. **Key point:** unlike `reverse()`, which mutates the array, `toReversed()` makes a clean (immutable) copy.Shown above the full answer for quick recall.Answer (EN)ImageThe `toReversed()` method is a **new, safe counterpart** to the older `reverse()` method, added in the ECMAScript 2023 (ES14) standard. ## What it does `toReversed()` returns a **new array** in which the elements are in **reverse order**, while the **original array is not changed**. ## Example: ```javascript const arr = [1, 2, 3]; const reversed = arr.toReversed(); console.log(reversed); // [3, 2, 1] console.log(arr); // [1, 2, 3] - the original stayed the same ``` Unlike `reverse()`, which **mutates** the array, `toReversed()` makes a **clean (immutable)** copy. ## Comparison with `reverse()` | Method | Changes the original array | Returns | | --- | --- | --- | | `reverse()` | Yes | The same array (mutated) | | `toReversed()` | No | A new array (reversed) | ## Comparison example: ```javascript const a = [1, 2, 3]; const b = a.reverse(); console.log(a); // [3, 2, 1] - changed console.log(b); // [3, 2, 1] - the same reference const c = a.toReversed(); console.log(c); // [1, 2, 3] - a new array console.log(a); // [3, 2, 1] - the original is untouched ``` ## When to use it - When you need to **safely reverse an array** without damaging the original. - Great for **functional and reactive programming**, where it's important not to mutate data (for example, in React or Redux). ## Briefly: | What it does | Creates a reversed copy of the array | | --- | --- | | Changes the original array | No | | Returns | A new array | | Added in | ECMAScript 2023 | | Example | `[1, 2, 3].toReversed()` -> `[3, 2, 1]` | ## Related non-mutating methods (ES2023+): JavaScript added a whole family of safe counterparts. | New method | Old mutating counterpart | What it does | | --- | --- | --- | | `toReversed()` | `reverse()` | Reverses the array | | `toSorted()` | `sort()` | Sorts without changing the original | | `toSpliced()` | `splice()` | Returns a modified copy | | `with()` | direct assignment by index | Returns a copy with a replaced element | > **Summary:** > `toReversed()` is a **non-mutating way to reverse an array**, > introduced in newer versions of JavaScript (ES2023). > > Safe, clean, predictable. > Does not change the original array.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.