Наші волонтери ще не переклали цю статтю мовою: Українська. Приєднуйтесь до нас і допоможіть зробити це!
Ви також можете прочитати статтю мовою English (US).

The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. 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.


new ArrayBuffer(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.


A RangeError is thrown if the length is larger than Number.MAX_SAFE_INTEGER (>= 2 ** 53) or negative.


The ArrayBuffer constructor creates a new ArrayBuffer of the given length in bytes.

Getting an array buffer from existing data


The ArrayBuffer constructor's length property whose value is 1.
get ArrayBuffer[@@species]
The constructor function that is used to create derived objects.
Allows the addition of properties to all ArrayBuffer objects.


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.


All ArrayBuffer instances inherit from ArrayBuffer.prototype.


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.


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.

Has the same functionality as ArrayBuffer.prototype.slice().


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);


Specification Status Comment
Typed Array Specification Obsolete Superseded by ECMAScript 6.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'ArrayBuffer' in that specification.
Standard Initial definition in an ECMA standard. Specified that new is required.
ECMAScript Latest Draft (ECMA-262)
The definition of 'ArrayBuffer' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic Support7 (Yes)41011.65.1
ArrayBuffer() without new throws ? ?44 ? ? ?
byteLength7 (Yes)41011.65.1
isView (Yes) (Yes)2911 (Yes) (Yes)
prototype7 (Yes)41011.65.1
slice (Yes) (Yes)12111 (Yes)6
transfer No No No No No No
@@species ? ?48 ? ? ?
FeatureAndroidChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic Support4 (Yes) (Yes)41011.64.2
ArrayBuffer() without new throws ? ? ?44 ? ? ?
byteLength4 (Yes) (Yes)41011.64.2
isView (Yes) (Yes) (Yes)2911 (Yes) (Yes)
prototype4 (Yes) (Yes)41011.64.2
slice (Yes) (Yes) (Yes)14111 (Yes)6
transfer No No No No No No No
@@species ? ? ?48 ? ? ?

1. The non-standard ArrayBuffer.slice() method has been removed in Firefox 53 (but the standardized version ArrayBuffer.prototype.slice() is kept.

Compatibility notes

Starting with ECMAScript 2015, ArrayBuffer constructors require to be constructed with a new operator. Calling an ArrayBuffer constructor as a function without new, will throw a TypeError from now on.

var dv = ArrayBuffer(10);
// TypeError: calling a builtin ArrayBuffer constructor 
// without new is forbidden
var dv = new ArrayBuffer(10);

See also

Мітки документа й учасники

 Востаннє оновлена: wolfram77,