byteLength
accessor property represents the length (in bytes) of this view from the start of its
ArrayBuffer
or
SharedArrayBuffer
.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
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 an
DataView
is constructed and cannot be changed. If the
DataView
is not specifying an offset or a
byteLength
,
byteLength
of the referenced
ArrayBuffer
or
SharedArrayBuffer
will be returned.
byteLength
property
var buffer = new ArrayBuffer(8); var dataview = new DataView(buffer); dataview.byteLength; // 8 (matches the byteLength of the buffer) var dataview2 = new DataView(buffer, 1, 5); dataview2.byteLength; // 5 (as specified when constructing the DataView) var dataview3 = new DataView(buffer, 2); dataview3.byteLength; // 6 (due to the offset of the constructed DataView)
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'DataView.prototype.byteLength' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
byteLength
|
Chrome 9 | Edge 12 | Firefox 15 | IE 10 | Opera 12.1 | Safari 5.1 | WebView Android 4 | Chrome Android 18 | Firefox Android 15 | Opera Android 12.1 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.10 |
完整支持
DataView
DataView.prototype.buffer
DataView.prototype.byteLength
DataView.prototype.byteOffset
DataView.prototype.getBigInt64()
DataView.prototype.getBigUint64()
DataView.prototype.getFloat32()
DataView.prototype.getFloat64()
DataView.prototype.getInt16()
DataView.prototype.getInt32()
DataView.prototype.getInt8()
DataView.prototype.getUint16()
DataView.prototype.getUint32()
DataView.prototype.getUint8()
DataView.prototype.setBigInt64()
DataView.prototype.setBigUint64()
DataView.prototype.setFloat32()
DataView.prototype.setFloat64()
DataView.prototype.setInt16()
DataView.prototype.setInt32()
DataView.prototype.setInt8()
DataView.prototype.setUint16()
DataView.prototype.setUint32()
DataView.prototype.setUint8()
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()