Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

TypedArray.prototype.reverse()

BaselineWidely available

Thereverse() method ofTypedArray instances reverses a typed arrayin place and returns the reference to the same typed array, the first typed array element now becoming the last, and the last typed array element becoming the first. In other words, elements order in the typed array will be turned towards the direction opposite to that previously stated. This method has the same algorithm asArray.prototype.reverse().

Try it

const uint8 = new Uint8Array([1, 2, 3]);uint8.reverse();console.log(uint8);// Expected output: Uint8Array [3, 2, 1]

Syntax

js
reverse()

Parameters

None.

Return value

The reference to the original typed array, now reversed. Note that the typed array is reversedin place, and no copy is made.

Description

SeeArray.prototype.reverse() for more details. This method is not generic and can only be called on typed array instances.

Examples

Using reverse()

js
const uint8 = new Uint8Array([1, 2, 3]);uint8.reverse();console.log(uint8); // Uint8Array [3, 2, 1]

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-%typedarray%.prototype.reverse

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp