JavaScripture
Contribute Feedback

JavaScript ArrayBuffer : Object

ArrayBuffers are fixed length buffer of bytes. The bytes in an ArrayBuffer are only accessible through a DataView (for heterogenous data) or one of the typed arrays (for homogeneous data): Float32Array, Float64Array, Int8Array, Int16Array, Int32Array, Uint8Array, Uint8ClampedArray, Uint16Array, Uint32Array. Multiple DataView and typed arrays can be applied to one ArrayBuffer and changes to one view can be seen in the others immediately.

Constructors

new ArrayBuffer(byteLength : Number) : ArrayBuffer

Allocates a new ArrayBuffer of the specified length where each byte starts as 0.

Example:

Run

Results:

 

Instance Properties

byteLength : Number  

The length of this in bytes.

Example:

Run

Results:

 

Instance Methods

slice(beginByte : Number, [endByte : Number]) : ArrayBuffer

Creates a new ArrayBuffer with a copy of the bytes of this between beginByte (inclusive) and endByte (exclusive). If endByte is not specified, this.byteLength is used. Changes to this do not affect the copy returned by slice.

Example:

Run

Results: