CKTIS / JavaScript
Int32Array: signed 32-bit integers
Int32Array stores numbers as signed 32-bit integers from -2147483648 through 2147483647, using 4 bytes per element.
Version: ECMAScript 2015 onward; example target: Node.js 24.22.2
Syntax
new Int32Array(); new Int32Array(length); new Int32Array(source); new Int32Array(buffer[, byteOffset[, length]])new Int32Array(source?, byteOffset?, length?) creates a numeric typed array from a length, iterable/array-like value, another numeric typed array, or an ArrayBuffer/SharedArrayBuffer. The buffer form shares bytes without copying, byteOffset must be a multiple of 4, and BYTES_PER_ELEMENT is 4.
Assignment applies ToNumber, truncates a fraction, reduces modulo 2^32, then interprets the result as signed. Thus 2147483648 becomes -2147483648, 4294967295 becomes -1, and NaN and infinities become 0. Assigning a BigInt or using a BigInt typed array as source throws TypeError. Byte order is native; use DataView for explicit endianness.
Length uses ToIndex: fractions truncate, NaN/undefined become 0, and -0.5 gives 0. A negative result after ToIntegerOrInfinity, infinity, a misaligned offset, or a range beyond the buffer throws RangeError; a detached buffer throws TypeError. The type has been standard since ECMAScript 2015.
Examples
const values = new Int32Array([2147483647, 2147483648, 4294967295, -2147483649, 3.9, NaN, Infinity]);
console.log(Array.from(values).join(","));
console.log(Int32Array.BYTES_PER_ELEMENT, new Int32Array(2.9).length, new Int32Array(-0.5).length);
const buffer = new ArrayBuffer(12);
const view = new Int32Array(buffer, 4, 1);
view[0] = -123456;
console.log(view.byteOffset, view.byteLength, view[0]);
try { view[0] = 1n; } catch (error) { console.log(error instanceof TypeError); }Result
2147483647,-2147483648,-1,2147483647,3,0,0 4 2 0 4 4 -123456 true