ArrayBuffer object is used to represent a generic 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 or a
DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer.
ArrayBuffer() constructor creates a new
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 is a transferable object.
ArrayBuffer objects can be made resizable by including the
maxByteLength option when calling the
ArrayBuffer() constructor. You can query whether an
ArrayBuffer is resizable and what its maximum size is by accessing its
maxByteLength properties, respectively. You can assign a new size to a resizable
ArrayBuffer with a
resize() call. New bytes are initialized to 0.
These features make resizing
Creates a new
The constructor function that is used to create derived objects.
argis one of the ArrayBuffer views, such as typed array objects or a
These properties are defined on
ArrayBuffer.prototype and shared by all
The size, in bytes, of the
ArrayBuffer. This is established when the array is constructed and can only be changed using the
ArrayBuffer.prototype.resize()method if the
The constructor function that created the instance object. For
ArrayBufferinstances, the initial value is the
The read-only maximum length, in bytes, that the
ArrayBuffercan be resized to. This is established when the array is constructed and cannot be changed.
ArrayBuffercan be resized, or
The initial value of the
@@toStringTagproperty is the string
"ArrayBuffer". This property is used in
ArrayBufferto the specified size, in bytes.
Returns a new
ArrayBufferwhose contents are a copy of this
ArrayBuffer's bytes from
begin(inclusive) up to
end(exclusive). If either
endis negative, it refers to an index from the end of the array, as opposed to from the beginning.
Creating an ArrayBuffer
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 Language Specification |
BCD tables only load in the browser