JavaScript Array toReversed()Method
Examples
Reverse the order of elements in an array:
//Create an array
const sites = ["Google", "Example", "JYSHARE", "Taobao"];
//Reverse the array
const sites2 = sites.toReversed();
document.getElementById("demo").innerHTML = sites2;
Output result:
Taobao,JYSHARE,Example,Google
Try it Yourself »
Definition and Usage
The toReversed() method is used to reverse the order of elements in an array.
The toReversed() method returns a new array.
The toReversed() method does not modify the original array.
toReversed() is the copying version of the reverse() method.
Browser Support
toReversed() is a feature of ES2023.
As of July 2023, all modern browsers support this feature:
| Chrome 110 | Edge 110 | Firefox 115 | Safari 16.4 | Opera 96 |
| Feb 2023 | Feb 2023 | Jul 2023 | Mar 2023 | May 2023 |
Syntax
array.toReversed()
Parameters
| Parameters | Description |
|---|---|
| None | None |
Return Value
| Type | Description |
|---|---|
| Array | Returns a new array with the element order reversed. The value of the last element that passes the test condition; if not found, returns undefined. |
Other Extensions
JavaScript Array Object