Reference
What structured clone does to a value. Companion to lesson 2. Normative walk: StructuredSerializeInternal.
| Bucket | What you get | Typical values |
|---|---|---|
| Keep | Same kind of value, new identity |
primitives (not symbol), Date, Map,
Set, arrays, ArrayBuffer,
Blob/File, cycles,
Error, undefined keys
|
| Flatten |
New Object with enumerable own
data only
|
class instances (methods + privates gone), getter results snapped to data properties |
| Throw | DataCloneError |
functions, DOM nodes, symbol values,
Promise, WeakMap/WeakSet,
Proxy
|
[[Get]] — getters
run; the result is stored as a data property.
Object.prototype. Your class prototype is not walked
and not restored.
| Value | Structured clone | JSON round-trip |
|---|---|---|
Date |
Keep (Date) |
ISO string |
Map / Set |
Keep | {} |
| Cycle | Keep (same-graph identity) | TypeError |
| Function field | Throw | Dropped / null |
| Class instance | Flatten to plain object | Flatten (and lose more types) |
undefined key |
Keep | Key dropped |
Clone stays a JavaScript value. A REST body still needs
JSON.stringify. Revival still needs a
custom serializer.