Reference

Structured clone glossary

Shared vocabulary for this workspace. Lessons stick to these meanings.

Structured clone
The platform algorithm that deep-copies (serialize, then deserialize) JavaScript values so they can cross realms or be stored. Used by postMessage, BroadcastChannel, IndexedDB, History state, and structuredClone(). Copies data, not behavior.
structuredClone()
The explicit API that runs the structured clone algorithm in the current realm: structuredClone(value) or structuredClone(value, { transfer }). Reach for it when you need a same-realm snapshot. Many APIs already clone for you.
Shallow copy
A new outer object whose property values are the same references as the original ({...obj}, Object.assign, array slice). Nested objects stay shared.
Deep copy
A copy that recursively duplicates nested objects so the result does not share identity with the original graph. Structured clone is the platform’s deep copy. JSON round-trip is a lossy substitute, not a synonym.
JSON round-trip
JSON.parse(JSON.stringify(value)). Produces a JSON document in the middle — not a faithful clone. Date becomes a string; Map/Set become {}; cycles and BigInt throw; functions and undefined are dropped or become null.
DataCloneError
Exception thrown when structured clone cannot serialize a value. Classic cases: functions and DOM nodes. Unlike JSON, it fails loudly instead of silently dropping those values.
Transferable object
A resource that can be moved (not copied) via a transfer list — e.g. ArrayBuffer, MessagePort, ImageBitmap. After transfer, the source is detached.
Transfer list
The array that marks which transferables move: structuredClone(value, { transfer }) or postMessage(value, transfer). It is not a second payload — listed objects must also appear in value, or they detach with nowhere to land.
Orphan transfer
A transferable that appears in the transfer list but is not reachable from the cloned / posted value. The source still detaches; the result never receives it.
Detached
State of a transferred resource the sender no longer owns. Typical ArrayBuffer symptom: byteLength === 0. A detached buffer cannot be cloned or transferred again.
Implicit clone
A platform API that runs structured clone for you — you pass a value in, you get a copy out later or on the other side. postMessage, BroadcastChannel, IndexedDB put/get, and history.pushState are implicit. Don’t structuredClone first unless you need a snapshot for another reason.
Custom serializer
App-defined encode/decode (often versioned) that can revive class instances, methods, or a stable wire format. Use when structured clone’s “plain data, new prototypes” result is not enough.
Realm
A JavaScript global environment (a window, a worker, an iframe document). Structured clone exists so values can leave one realm and appear as new objects in another — or come back as a new object in the same realm via structuredClone().
Keep
Clone result is the same kind of value (a Date stays a Date), with new identity. Cycles keep their self-links via the memory map.
Flatten
Clone result is a new ordinary object (Object.prototype) holding enumerable own data only. Methods, private fields, and the original prototype are gone. This is what happens to class instances.
Throw
The algorithm cannot serialize the value, so it raises DataCloneError. Functions, DOM nodes, symbol values, Promise, WeakMap, and Proxy land here.
Enumerable own property
A property on the object itself (not the prototype) that shows up in Object.keys / for…in. Structured clone walks these, then reads them with [[Get]] (getters run). Symbol keys are dropped.
Memory map
The spec’s “already seen this object” table used while serializing. If a reference appears again, the clone reuses the earlier copy — that is why cycles and shared sub-objects keep identity.