このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

TypedArray.prototype.toReversed()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年7月.

toReversed()TypedArray インスタンスのメソッドで、 reverse() メソッドに対応するコピーメソッドです。このメソッドは、要素を逆順にした新しい型付き配列を返します。このメソッドは Array.prototype.toReversed() と同じアルゴリズムです。

構文

js
toReversed()

引数

なし。

返値

要素を逆順に格納した新しい型付き配列です。

解説

詳細については、 Array.prototype.toReversed() をご覧ください。このメソッドは汎用的ではなく、型付き配列インスタンスに対してのみ呼び出すことができます。

toReversed() の使用

js
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]

仕様書

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

ブラウザーの互換性

関連情報