JavaScript ArrayBuffer Object
An ArrayBuffer is a fixed-length block of raw binary memory. You can't read it directly; you read and write it through a typed array or a DataView.
Description
An ArrayBuffer represents a block of raw binary data of a given number of bytes. It has no methods for reading its contents; instead you create a view over it, such as a Uint8Array or a DataView, which interprets the bytes as numbers of a certain type.
Binary data from fetch() responses, files and WebSockets often arrives as an ArrayBuffer. Buffers can be resizable (with the maxByteLength option and resize()), sliced into copies with slice(), and transferred to workers without copying.
An ArrayBuffer can be transferred to a web worker with postMessage(), which moves the memory instead of copying it and leaves the original buffer empty (detached). The transfer() method does the same within a single thread. To read text from a buffer, use TextDecoder, and to turn text into bytes, TextEncoder.
Creating
new ArrayBuffer(byteLength)
new ArrayBuffer(byteLength, { maxByteLength })Example
Browser Support
The following information will show you the current browser support for the ArrayBuffer object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





