SharedArrayBuffer.prototype.byteLength
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年12月.
byteLength アクセサープロパティは、SharedArrayBuffer の長さをバイト単位で表します。
解説
byteLength プロパティは、 set アクセサー関数が undefined であるアクセサープロパティです。つまり、このプロパティは読み取り専用です。値は共有配列が生成されたときに決定され、変更できません。
例
これらの例は、コンソールや任意のウェブページから直接実行することはできません。SharedArrayBuffer は、そのセキュリティ要件が満たされない限り定義されないからです。
byteLength の使用
js
const sab = new SharedArrayBuffer(1024);
sab.byteLength; // 1024
仕様書
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-get-sharedarraybuffer.prototype.bytelength> |