JavaScripture
Contribute via GitHub Feedback

JavaScript Uint32Array : ArrayBufferView

Uint32Array is similar to an Array where each item is a 32 bit (4 byte) unsigned integer. Uint32Arrays cannot change size after creation.

Constructors

new Uint32Array(length : Number) : Uint32Array

Creates a new Uint32Array of the specified length where each item starts out as 0

Example:

Run

Results:

 

new Uint32Array(array : Array) : Uint32Array

Creates a new Uint32Array and copies the items of array into this. The copied items are converted to 32 bit unsigned integers before being stored in this.

Example:

Run

Results:

 

new Uint32Array(array : Uint32Array) : Uint32Array

Creates a new Uint32Array and copies the items of array into this. array can be any of the typed array types and the copied items will be converted to 32 bit unsigned integers before being stored in this.

Example:

Run

Results:

 

new Uint32Array(buffer : ArrayBuffer, [byteOffset = 0 : Number, [length : Number]]) : Uint32Array

Creates a view on top of the specified buffer starting at byteOffset of length items. Changes to the items in this actual affect the underlying buffer, and vice versa. byteOffset must be a multiple of 4. (Use DataView for unaligned data.) If length is not specified, buffer.length - byteOffset must be a multiple of 4 and this.length will be (buffer.length - byteOffset) / 4.

Example:

Run

Results:

 

Instance Indexers

this[index : Number] : Number

Gets and sets the element in this at index. index should be between 0 and this.length - 1.

Example:

Run

Results:

 

Instance Properties

buffer : ArrayBuffer  

Returns the underlying buffer for this Uint32Array.

Example:

Run

Results:

 

byteLength : Number  

The length of this in bytes.

Example:

Run

Results:

 

byteOffset : Number  

The offset into this.buffer where the 0th item is stored.

Example:

Run

Results:

 

length : Number  

The number of elements in this. It is 1 greater than the index of the last item.

Example:

Run

Results:

 

Instance Methods

set 2 variants
set(array : Array, [offset = 0 : Number]) : undefined

Copies items from array into this starting at this[offset]. Copied items are converted to 32 bit ints before storing in this.

Example:

Run

Results:

 

set(array : Uint32Array, [offset = 0 : Number]) : undefined

Copies items from array into this starting at this[offset]. array can be any of the typed array types and the copied items will be converted to 32 bit ints before storing in this.

Example:

Run

Results:

 

subarray(begin : Number, [end : Number]) : Uint32Array

Returns a new Uint32Array that is a view on top of this containing items this[begin], this[begin + 1], ..., this[end - 1]. The 0th item in the returned array in the same memory location as this[begin]. If end is not specified, this.length is used.

Example:

Run

Results:

 

Uint32Array Properties

BYTES_PER_ELEMENT : Number

Returns the size in bytes of an item in a Uint32Array.

Example:

Run

Results: