Skip to content

API UInt32Array

Liu.Yandong.Hanks edited this page Aug 21, 2026 · 1 revision

UInt32Array

Fixed-length packed array of unsigned 32-bit integers.

Script API Reference

Overview

UInt32Array is a primitive-backed array for allocation-efficient unsigned numeric workloads such as hashes, packed colors, and non-negative counters. Elements live in contiguous native storage, so the array avoids the per-element object allocation of a general Array.

The length is fixed at construction. push, pop, and element deletion are unavailable; elements are read and written through numeric indexes.

var hashes = new UInt32Array(2);
hashes[0] = 4294967295;
return hashes[0]; // 4294967295

Warning

Indexing outside 0 to length - 1 raises a runtime error. Validate computed indexes before reading or writing.

Use Int32Array when values must be signed, or Array when the element type must vary or the collection has to grow.

Constructors

new UInt32Array([length])

Parameters

Name Type Required Description
length number No Non-negative element count. Omitting it creates an empty array.

Returns

UInt32Array — a fixed-length array whose elements start at 0.

Example

var colors = new UInt32Array(4);
return colors[3]; // 0

Properties

values.length

Returns

number — the fixed element count.

Behavior

Read-only. The value never changes for a given instance.

Example

return new UInt32Array(8).length; // 8

Methods

values.fill([value])

Parameters

Name Type Required Description
value number No Value written to every element. Defaults to 0.

Returns

UInt32Array — this array, so calls can be chained.

Behavior

The value is converted to an unsigned 32-bit integer before it is stored, and every element is overwritten in place.

Example

var colors = new UInt32Array(3);
colors.fill(16711680);
return colors[2]; // 16711680

Clone this wiki locally