TypedArray.prototype.byteOffset

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

byteOffsetTypedArray インスタンスのアクセサープロパティで、この型付き配列の ArrayBuffer または SharedArrayBuffer の開始位置からの(バイト単位の)オフセットを返します。

解説

byteOffset プロパティは set アクセサープロパティが undefined であるアクセサープロパティです。これは、このプロパティが読み取り専用であることを意味します。値は TypedArray が構築されたときに確立し、変更することができません。 TypedArray型付き配列オブジェクトのうちの一つです。

byteOffset プロパティの使用

js
const buffer = new ArrayBuffer(8);

const uint8array1 = new Uint8Array(buffer);
uint8array1.byteOffset; // 0 (no offset specified)

const uint8array2 = new Uint8Array(buffer, 3);
uint8array2.byteOffset; // 3 (as specified when constructing Uint8Array)

仕様書

Specification
ECMAScript Language Specification
# sec-get-%typedarray%.prototype.byteoffset

ブラウザーの互換性

BCD tables only load in the browser

関連情報