JavaScript TypedArray Object
Typed arrays, such as Uint8Array and Float32Array, are array-like views of raw binary data where every element has the same numeric type. They are used for files, images, audio, WebGL and network data.
Description
Typed arrays are array-like objects for working with raw binary data. TypedArray isn't a global you use directly; it is the shared parent of eleven concrete types: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array and BigUint64Array (plus Float16Array in newer browsers). Every element has the same type and size, and values are converted to fit, so new Uint8Array([300]) stores 44.
A typed array is a view on an ArrayBuffer, and several views can share the same memory. They have most array methods, such as map(), slice() and includes(), but have a fixed length. They are used by the Canvas, WebGL, Web Audio, fetch() (via arrayBuffer()), file reading and WebSockets.
Unlike regular arrays, typed arrays can't grow or shrink, and assigning a value of the wrong type converts it rather than storing it as is. subarray() creates a new view over part of the same memory without copying, whereas slice() copies. Use Array.from(typed) or spread syntax to convert one to a normal array when you need to store mixed values.
Creating
new Uint8Array(length)
new Float32Array(array)
new Int16Array(buffer, byteOffset, length)Example
Browser Support
The following information will show you the current browser support for the TypedArray object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





