ArrayBuffer() constructor is used to create
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.
- The size, in bytes, of the array buffer to create.
ArrayBuffer object of the specified size. Its contents are
initialized to 0.
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
TypeError from now on.
var dv = ArrayBuffer(10); // TypeError: calling a builtin ArrayBuffer constructor // without new is forbidden
var dv = new ArrayBuffer(10);
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);
BCD tables only load in the browser