ArrayBuffer
object is used to represent a generic, fixed-length raw binary data buffer.
It is an array of bytes, often referred to in other languages as a "byte array".You cannot directly manipulate the contents of an
ArrayBuffer
; instead, you create one of the
typed array objects
或
DataView
object which represents the buffer in a specific format, and use that to read and write the contents of the buffer.
ArrayBuffer()
构造函数创建新
ArrayBuffer
of the given length in bytes. You can also get an array buffer from existing data, for example
from a Base64 string
or
from a local file
.
ArrayBuffer()
ArrayBuffer
对象。
get ArrayBuffer[@@species]
The constructor function that is used to create derived objects.
ArrayBuffer.isView(
arg
)
true
if
arg
is one of the ArrayBuffer views, such as
typed array objects
或
DataView
。返回
false
否则。
ArrayBuffer.prototype.byteLength
ArrayBuffer
. This is established when the array is constructed and cannot be changed.
ArrayBuffer.prototype.slice()
ArrayBuffer
whose contents are a copy of this
ArrayBuffer
's bytes from
begin
(inclusive) up to
end
(exclusive). If either
begin
or
end
is negative, it refers to an index from the end of the array, as opposed to from the beginning.
In this example, we create a 8-byte buffer with a
Int32Array
view referring to the buffer:
const buffer = new ArrayBuffer(8); const view = new Int32Array(buffer);
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'ArrayBuffer' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ArrayBuffer
|
Chrome 7 | Edge 12 | Firefox 4 | IE 10 | Opera 11.6 | Safari 5.1 | WebView Android 4 | Chrome Android 18 | Firefox Android 4 | Opera Android 12 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.10 |
ArrayBuffer()
构造函数
|
Chrome 7 | Edge 12 | Firefox 4 | IE 10 | Opera 11.6 | Safari 5.1 | WebView Android 4 | Chrome Android 18 | Firefox Android 4 | Opera Android 12 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.10 |
byteLength
|
Chrome 7 | Edge 12 | Firefox 4 | IE 10 | Opera 11.6 | Safari 5.1 | WebView Android 4 | Chrome Android 18 | Firefox Android 4 | Opera Android 12 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.10 |
isView
|
Chrome 32 | Edge 12 | Firefox 29 | IE 11 | Opera 19 | Safari 7 | WebView Android ≤37 | Chrome Android 32 | Firefox Android 29 | Opera Android 19 | Safari iOS 7 | Samsung Internet Android 2.0 | nodejs 4.0.0 |
slice
|
Chrome 17 | Edge 12 |
Firefox
12
|
IE 11 | Opera 12.1 | Safari 6 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
14
|
Opera Android 12.1 | Safari iOS 6 | Samsung Internet Android 1.0 | nodejs 0.12 |
@@species
|
Chrome 51 | Edge 13 | Firefox 48 | IE No | Opera 38 | Safari 10 | WebView Android 51 | Chrome Android 51 | Firefox Android 48 | Opera Android 41 | Safari iOS 10 | Samsung Internet Android 5.0 |
nodejs
6.5.0
|
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
ArrayBuffer
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()