ArrayBuffer Object

Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.

For more information about typed arrays, see Typed Arrays.


arrayBuffer = new ArrayBuffer(length);  


Required. The variable name to which the ArrayBuffer object is assigned.

The length of the buffer. The contents of the ArrayBuffer are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.


The following table lists the properties of the ArrayBuffer object.

Property Description
byteLength Property Read-only. The length of the ArrayBuffer (in bytes).


The following table lists the functions of the ArrayBuffer object.

Property Description
ArrayBuffer.isView Function Determines whether an object provides a view of the buffer.


The following table lists the methods of the ArrayBuffer object.

Property Description
slice Method Returns a section of an ArrayBuffer.


The following example shows how to use an ArrayBuffer object to process the binary data acquired from an XMLHttpRequest. You can use a DataView Object to get the individual values.

var req = new XMLHttpRequest();'GET', "");  
    req.responseType = "arraybuffer";  

    req.onreadystatechange = function () {  
        if (req.readyState === 4) {  
            var buffer = req.response;  
            var dataview = new DataView(buffer);  
            var ints = new Int32Array(buffer.byteLength / 4);  
            for (var i = 0; i < ints.length; i++) {  
                ints[i] = dataview.getInt32(i * 4);  


For more information about using XmlHttpRequest, see XMLHttpRequest enhancements.


Supported in the following document modes: Internet Explorer 10 standards and Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards.