ArrayBuffer.prototype.byteLength

ArrayBuffer 实例的 byteLength 访问器属性返回此数组缓冲区的长度(以字节为单位)。

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

Try it

描述

¥Description

byteLength 属性是一个访问器属性,其设置的访问器函数为 undefined,这意味着你只能读取该属性。该值是在构造数组时确定的,并且无法更改。如果此 ArrayBuffer 已分离,则此属性返回 0。

¥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 array is constructed and cannot be changed. This property returns 0 if this ArrayBuffer has been detached.

示例

¥Examples

使用字节长度

¥Using byteLength

js
const buffer = new ArrayBuffer(8);
buffer.byteLength; // 8

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also