arrayBuffer.byteLength

arrayBuffer.byteLength

byteLength访问器属性表示一个ArrayBuffer对象的字节长度。

语法

arraybuffer.byteLength

描述

byteLength属性是一个访问器属性,它的set访问器函数是undefined,这意味着你只能读这个属性。 该值在数组创建时确定,并且不可变更。如果这个ArrayBuffer被移除,则此属性返回0。

示例

var buffer = new ArrayBuffer(8 buffer.byteLength; // 8

规范

SpecificationStatusComment
Typed Array SpecificationObsoleteSuperseded by ECMAScript 2015.
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'ArrayBuffer.prototype.byteLength' in that specification.StandardInitial definition in an ECMA standard.
ECMAScript Latest Draft (ECMA-262)The definition of 'ArrayBuffer.prototype.byteLength' in that specification.Draft

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support7.0(Yes)4.0 (2)1011.65.1

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support4.0(Yes)(Yes)4.0 (2)1011.64.2