ArrayBuffer

The ArrayBuffer is a data type that is used to represent a generic, fixed-length binary data buffer. You can't directly manipulate the contents of an ArrayBuffer; instead, you create an ArrayBufferView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer.

Method overview

ArrayBuffer ArrayBuffer(unsigned long length);

Attributes

Attribute Type Description
byteLength unsigned long The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. Read only.

Methods

ArrayBuffer()

The constructor accepts as input a byte length for the new buffer, and returns the newly-created ArrayBuffer object.

ArrayBuffer ArrayBuffer(
  unsigned long length
);
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.

Example

In this example, we create a 32-byte buffer:

var buf = new ArrayBuffer(32);

Browser compatibility

  • Desktop
  • Mobile

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 7 4.0 (2) 10 11.6 5.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 4.0 4.0 (2) -- -- 4.2

Tags (2)

Edit tags

Attachments (0)

 

Attach file