TypedArray.prototype.toReversed()
En esta página
The toReversed() method of {{jsxref("TypedArray")}} instances is the copying counterpart of the {{jsxref("TypedArray/reverse", "reverse()")}} method. It returns a new typed array with the elements in reversed order. This method has the same algorithm as {{jsxref("Array.prototype.toReversed()")}}.
Syntax#
toReversed()
Parameters#
None.
Return value#
A new typed array containing the elements in reversed order.
Description#
See {{jsxref("Array.prototype.toReversed()")}} for more details. This method is not generic and can only be called on typed array instances.
Examples#
Using toReversed()#
const uint8 = new Uint8Array([1, 2, 3]);
const reversedUint8 = uint8.toReversed();
console.log(reversedUint8); // Uint8Array [3, 2, 1]
console.log(uint8); // Uint8Array [1, 2, 3]
Specifications#
{{Specifications}}
Browser compatibility#
{{Compat}}
See also#
- Polyfill of
TypedArray.prototype.toReversedincore-js - JavaScript typed arrays guide
- {{jsxref("TypedArray.prototype.reverse()")}}
- {{jsxref("TypedArray.prototype.toSorted()")}}
- {{jsxref("TypedArray.prototype.with()")}}
- {{jsxref("Array.prototype.toReversed()")}}