Advertisement
Intermediate JavaScript, ArrayBuffer, TypedArrays & Binary Data

How do you convert a TypedArray to a regular JavaScript array?

Short answer

Use Array.from() or the spread operator; both iterate the TypedArray and produce a standard Array with full array method support (map, filter, etc.), which TypedArrays only partially share.

Save JavaScript mock interview
Advertisement
AModel answer
Use Array.from() or the spread operator; both iterate the TypedArray and produce a standard Array with full array method support (map, filter, etc.), which TypedArrays only partially share.
const typed = new Uint8Array([1, 2, 3]);
const arr = Array.from(typed);
console.log(arr); // [1, 2, 3]
Real-world example
Converting decoded audio sample data into a regular array before running custom analysis functions.
Likely follow-ups
  • Do TypedArrays support push() and pop()?
Related topics