Raw memory and views
An ArrayBuffer is a fixed length block of raw binary data. You cannot touch its bytes directly. Instead you create a typed array view, such as Uint8Array or Float64Array, that interprets the bytes as numbers of a specific type.
- The buffer holds the bytes, the view gives them meaning.
- Different views can share one buffer.
- Indexing a view reads or writes at a typed offset.
Why typed arrays exist
Typed arrays give compact, predictable memory for performance sensitive work like graphics, audio, and binary protocols. They store numbers in a contiguous block with no boxing.
- WebGL, canvas pixels, and fetch bodies use them.
- A DataView lets you read mixed types and control byte order.
- Out of range writes are ignored rather than growing the array.
Because several views can overlap the same buffer, you can reinterpret the same bytes as different types, which is powerful but easy to misuse. The split between buffer and view is the core idea: storage and interpretation are separate concerns.
Key idea
An ArrayBuffer stores raw bytes while typed array views interpret them, letting multiple views share and reinterpret the same memory.