--- title: SharedArrayBuffer.prototype.byteLength slug: Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength tags: - SharedArrayBuffer translation_of: Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength ---
byteLength
访问器属性表示以字节为单位的一个{{jsxref("SharedArrayBuffer")}}的长度。
sab.byteLength
byteLength
属性是一个访问者属性,其set访问者函数为 undefined
,这意味着您只能读取此属性。 该值在构造共享数组时建立,并且无法更改。
var sab = new SharedArrayBuffer(1024); sab.byteLength; // 1024
Specification | Status | Comment |
---|---|---|
{{SpecName('ESDraft', '#sec-get-sharedarraybuffer.prototype.bytelength', 'SharedArrayBuffer.prototype.byteLength')}} | {{Spec2('ESDraft')}} | Initial definition in ES2017. |
{{Compat("javascript.builtins.SharedArrayBuffer.byteLength")}}