JavaScript Typed Arrays

By: Dusty Arlia
Published on Monday, March 3, 2014, 08:38 PM
Last Updated on Saturday, July 11, 2015 at 8:30 PM
Total Updates: 3

Typed arrays are array-like objects, but they differ from regular arrays in these ways:

- All the elements are numbers
- The constructor used to create the typed array determines the type and size of the numbers.
    •Types: signed integers, unsigned integers, or floating point
    •Size: in bits
- Typed arrays have a fixed length
- The elements are always initialized to 0 when the array is created

There are eight kinds of typed arrays (each with a different element type). You can create them with these constructors:

Constructor Numeric Type
Int8Array() Signed bytes
Uint8Array() Unsigned bytes
Int16Array() Signed 16-bit short integers
Uint16Array() Unsigned 16-bit short integers
Int32Array() Signed 32-bit integers
Uint32Array() Unsigned 32-bit integers
Float32Array() 32-bit floating-point value
Float64Array() 64-bit floating-point value: a regular JavaScript number