ArrayBuffer

Table of contents

  1. 1. Method overview
  2. 2. Attributes
  3. 3. Methods
    1. 3.1. ArrayBuffer()
  4. 4. Example
  5. 5. See also

Introduced in Gecko 2

(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
DRAFT
This page is not complete.

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

Tags (2)

Attachments (0)

 

Attach file