JavaScript Array toReversed()
Example
// Create an Array
const fruits = ["Banana", "Orange", "Apple", "Mango"];
// Reverse the Array
const fruits2 = fruits.toReversed();
Try it Yourself »const fruits = ["Banana", "Orange", "Apple", "Mango"];
// Reverse the Array
const fruits2 = fruits.toReversed();
Description
ThetoReversed() method reverses the order of the elements in an array.
ThetoReversed() method returns a new array.
ThetoReversed() methoddoes not overwrites the original array.
ThetoReversed() method is thecopying version of thereverse() method.
Array Sort Methods:
| Method | Finds |
|---|---|
| reverse() | Reverses the order of the elements in an array |
| sort() | Sorts the elements of an array |
| toReversed() | Reverses the elements of an array into a new array |
| toSorted() | Sorts the elements of an array into a new array |
Syntax
array.toReversed()
Parameters
| NONE |
Return Value
| Type | Description |
| Array | A new array with the items reversed. |
Array Tutorials:
Browser Support
toReversed() is a JavaScript 2023 feature.
ES 2023 is supported in all modern browsers sinceJuly 2023:
| Chrome 110 | Edge 110 | Firefox 115 | Safari 16.4 | Opera 96 |
| Feb 2023 | Feb 2023 | Jul 2023 | Mar 2023 | May 2023 |

