Advertisement
Beginner JavaScript, ArrayBuffer, TypedArrays & Binary Data

What is a TypedArray and how does it relate to ArrayBuffer?

Short answer

A TypedArray (like Int32Array, Uint8Array, Float64Array) is a view that lets you read and write numeric values of a specific type directly into an ArrayBuffer's memory, without copying data.

Save JavaScript mock interview
Advertisement
AModel answer
A TypedArray (like Int32Array, Uint8Array, Float64Array) is a view that lets you read and write numeric values of a specific type directly into an ArrayBuffer's memory, without copying data.
const buffer = new ArrayBuffer(4);
const view = new Int32Array(buffer);
view[0] = 42;
console.log(view[0]); // 42
Real-world example
Decoding pixel data from a Canvas ImageData object uses a Uint8ClampedArray.
Likely follow-ups
  • Can multiple TypedArrays share the same ArrayBuffer?
Related topics