TypedArray.prototype.reverse()

reverse() メソッドは、その場で型付き配列を反転します。型付き配列の先頭の要素は末尾になり、末尾の要素は先頭になります。このメソッドは Array.prototype.reverse() と同じアルゴリズムです。 TypedArray は、ここでは 型付き配列型のうちの一つです。

試してみましょう

構文

reverse()

返値

反転された配列です。

reverse の使用

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

console.log(uint8); // Uint8Array [3, 2, 1]

仕様書

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

ブラウザーの互換性

BCD tables only load in the browser

関連情報