JavaScript Array toReversed()
Example
// Create an Array
const fruits = ["Banana", "Orange", "Apple", "Mango"];
// Reverse the Array
const fruits2 = fruits.toReversed();
Try it Yourself »
Description
The toReversed() method reverses the order of the elements in an array.
The toReversed() method returns a new array.
The toReversed() method does not overwrites the original array.
The toReversed() method is the copying version of the
reverse() 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 since July 2023:
| Chrome 110 |
Edge 110 |
Firefox 115 |
Safari 16.4 |
Opera 96 |
| Feb 2023 | Feb 2023 | Jul 2023 | Mar 2023 | May 2023 |