Closer to the Metal
Regular JS arrays ([]) are flexible but heavy objects. When you need to process millions of numbers (video, audio, 3D graphics), they become too slow. This is where TypedArrays come in.
1. How they work
Typed arrays reserve a " chunk " of memory of a fixed size and store data there purely in binary form.
2. Main Types
Uint8Array: Numbers from 0 to 255. 1 byte per number. Ideal for images.Int32Array: 32-bit integers (4 bytes).Float64Array: High precision for mathematical calculations.
let buffer = new Uint8Array(2);
buffer[0] = 255;
buffer[1] = 256; // An "overflow" wrap-around occurs, it becomes 0.
Note
Typed arrays cannot be expanded. Their length is fixed upon creation. If you need more space, you'll have to create a new array.
Tip
Most modern APIs (WebCrypto, Canvas, Bluetooth) work specifically with TypedArrays and ArrayBuffer.