Typed Array toReversed()
Example
// Create a Typed Array
const myArr = Int16Array.from([10,15,20,25,30,35,40,45,50]);
// Reverse the Array into a new Array
const newArr = myArr.toReversed();
Try it Yourself »
Description
The toReversed() method reverses a typed array into a new array.
The toReversed() method toes not change the original array.
Typed Array Sort Methods:
| Method | Finds |
|---|---|
| reverse() | Reverses the order of the elements in an array |
| sort() | Sorts the order of the elements in 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
typed-array.toReversed()
|
typed-array must be one of the following: Int8ArrayUint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float16Array Float32Array Float64Array BigInt64Array BigUint64Array |
Parameters
| NONE |
Return Value
| Type | Description |
| Typed Array | A new array with the elements reversed. |
JavaScript Typed Arrays
Browser Support
typed-array.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 |