SharedArrayBuffer.prototype.byteLength

SharedArrayBuffer 实例的 byteLength 访问器属性返回此 SharedArrayBuffer 的长度(以字节为单位)。

¥The byteLength accessor property of SharedArrayBuffer instances returns the length (in bytes) of this SharedArrayBuffer.

Try it

描述

¥Description

byteLength 属性是一个访问器属性,其设置的访问器函数为 undefined,这意味着你只能读取该属性。该值是在构建共享数组时确定的,并且不能更改。

¥The byteLength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when the shared array is constructed and cannot be changed.

示例

¥Examples

使用字节长度

¥Using byteLength

js
const sab = new SharedArrayBuffer(1024);
sab.byteLength; // 1024

规范

Specification
ECMAScript Language Specification
# sec-get-sharedarraybuffer.prototype.bytelength

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also