JS Array Buffer
JS Array Buffer
Parameters
length
The size, in bytes, of the array buffer to create.
Return value
A new ArrayBuffer object of the specified size. Its contents are initialized
to 0.
Exceptions
A RangeError is thrown if the length is larger
than Number.MAX_SAFE_INTEGER (>= 2 ** 53) or negative.
Description
The ArrayBuffer constructor creates a new ArrayBuffer of the given
length in bytes.
Properties
ArrayBuffer.length
The ArrayBuffer constructor's length property whose value is 1.
get ArrayBuffer[@@species]
The constructor function that is used to create derived objects.
ArrayBuffer.prototype
Allows the addition of properties to all ArrayBuffer objects.
Methods
ArrayBuffer.isView(arg)
Returns true if arg is one of the ArrayBuffer views, such as typed
array objects or a DataView. Returns false otherwise.
ArrayBuffer.transfer(oldBuffer [, newByteLength])
Returns a new ArrayBuffer whose contents are taken from the oldBuffer's data and then
is either truncated or zero-extended by newByteLength.
Instances
All ArrayBuffer instances inherit from ArrayBuffer.prototype.
Properties
ArrayBuffer.prototype.constructor
Specifies the function that creates an object's prototype. The initial
value is the standard built-in ArrayBuffer constructor.
ArrayBuffer.prototype.byteLength Read only
The size, in bytes, of the array. This is established when the array is
constructed and cannot be changed. Read only.
Methods
ArrayBuffer.prototype.slice()
Returns a new 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.
ArrayBuffer.slice()
Has the same functionality as ArrayBuffer.prototype.slice().
Example
In this example, we create a 8-byte buffer with a Int32Array view
referring to the buffer:
var buffer = new ArrayBuffer(8);
var view = new Int32Array(buffer);
Specifications
Specification Status Comment
Typed Array Specification Obsolete Superseded by ECMAScript 6.
ECMAScript 2015 (6th Edition, Standard Initial definition in an ECMA standard.
ECMA-262) Specified that new is required.
The definition of 'ArrayBuffer' in that
specification.
Browser compatibility
Desktop
Mobile
Feature Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 7 Yes 4 10 11.6 5.1