Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Uint32Array — unsigned 32-bit integer array

Uint32Array is a typed buffer view: each element occupies 4 bytes and stores a number from 0 to 4294967295. Learn value conversion, view construction, and the difference between sharing memory and copying.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

new Uint32Array(length)
new Uint32Array(iterableOrArrayLike)
new Uint32Array(typedArray)
new Uint32Array(buffer[, byteOffset[, length]])

Uint32Array is a typed array: a memory view whose elements are read as Number values from 0 to 4294967295. Each occupies 4 bytes; length counts elements, while byteLength counts bytes. It is not an ordinary Array and has no push() method.

new Uint32Array(length) creates a zero-filled buffer. Construction from an iterable or another typed array with Number elements copies values. Construction from a BigInt64Array or BigUint64Array throws TypeError, even if the source is empty. Construction from an ArrayBuffer shares its memory. byteOffset must be a multiple of 4; an explicit length counts elements, not bytes.

Writing applies ToUint32 conversion: truncate toward zero, then take the result modulo 2 ** 32. Thus -1 becomes 4294967295, and 2 ** 32 + 7 becomes 7. NaN and infinities become 0; writing a BigInt throws TypeError. This is conversion, not range validation.

subarray() shares memory, whereas slice() copies elements. Byte order is native to the implementation; use DataView for binary formats requiring explicit byte order. In the example, changing view[0] also changes values[1].

Examples

const values = new Uint32Array([1, -1, 2 ** 32 + 7, 3.9]);
const view = values.subarray(1, 3);
view[0] = 42;
console.log(values.join(","));
console.log(values.length, values.byteLength, Uint32Array.BYTES_PER_ELEMENT);

Result

1,42,7,3
4 16 4

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources