ArrayBuffer
Raw fixed-length bytes.
ArrayBuffer stores raw bytes. DataView reads those bytes with explicit types and byte order. Atomics coordinates shared memory.
const buffer = new ArrayBuffer(4); const view = new DataView(buffer); view.setUint16(0, 513, false); console.log(view.getUint16(0, false));
JSON & Structured Data
ArrayBuffer is a fixed-length raw byte buffer. It does not say what the bytes mean by itself.
DataView lets you read and write numbers at byte offsets with explicit endianness. This matters for binary formats and network protocols.
Atomics works with SharedArrayBuffer and integer typed arrays to coordinate memory between threads. It is specialized and should be used carefully.
Raw fixed-length bytes.
Reads and writes typed values at byte offsets.
Byte order: big-endian or little-endian.
Safe shared-memory operations for workers.
Examples
const view = new DataView(new ArrayBuffer(4)); view.setUint16(0, 513, false); const value = view.getUint16(0, false);
view.setUint16(0, 513); const value = view.getUint16(0); // Readers cannot see whether byte order was intentional.
Code patterns
These patterns focus on the data boundaries you will use constantly: JSON, URLs, forms, files, fetch objects and binary buffers.
Allocate raw bytes.
const buffer = new ArrayBuffer(8);
Use byte offsets and explicit type.
const view = new DataView(buffer); view.setUint16(0, 513, false); console.log(view.getUint16(0, false));
The third argument controls byte order.
view.setUint16(0, 513, true); console.log(view.getUint16(0, true));
Use feature checks for shared memory support.
if (typeof SharedArrayBuffer !== "undefined") {
const shared = new SharedArrayBuffer(4);
const values = new Int32Array(shared);
Atomics.add(values, 0, 1);
}
Rules that matter
Structured data becomes reliable when every boundary is explicit: text to object, form to values, URL to parameters, response to JSON and bytes to meaning.
The buffer stores bytes, not meaning.
Offsets and types stay explicit.
Endianness bugs are hard to spot.
Binary reads can go out of range.
Most application code does not need it.
Browser security requirements can affect availability.
Production thinking
Structured binary code needs precision. DataView makes byte offset, type and byte order visible.
Binary processing errors should become clear UI messages instead of silent failures.
Production binary parsers should test byte order, invalid sizes and unsupported shared memory paths.
Binary APIs do not affect crawled text directly, but generated data should be labeled clearly when displayed.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Structured data is safe only when you know where it came from, what shape it has and what conversion happened before use.
Senior audit upgrade
Atomics and SharedArrayBuffer are specialized tools for concurrent work. Learn the concept, but do not treat it as day-one web development.
Last reviewed: 11 June 2026. Browser Atomics often depends on SharedArrayBuffer and cross-origin isolation. Treat it as specialized infrastructure work.
Chapter checkpoint
Finish this chapter by turning the lessons into a small practical proof.
Build a small example that combines three lessons from this chapter.
Can you explain the important tradeoff without reading from the page?