SharedArrayBuffer.prototype.byteLength
byteLength 訪問器屬性,屬於 SharedArrayBuffer 例項,返回此 SharedArrayBuffer 的長度(以位元組為單位)。
試一試
// Create a SharedArrayBuffer with a size in bytes
const buffer = new SharedArrayBuffer(8);
console.log(buffer.byteLength);
// Expected output: 8
描述
byteLength 屬性是一個訪問器屬性,其 set 訪問器函式為 undefined,這意味著您只能讀取此屬性。該值在共享陣列構造時建立,且無法更改。
示例
使用 byteLength
js
const sab = new SharedArrayBuffer(1024);
sab.byteLength; // 1024
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-get-sharedarraybuffer.prototype.bytelength |
瀏覽器相容性
載入中…