The structured clone algorithm copies complex JavaScript objects. It is used internally when invoking structuredClone()
, to transfer data between Workers via postMessage()
, storing objects with IndexedDB, or copying objects for other APIs.
It clones by recursing through the input object while maintaining a map of previously visited references, to avoid infinitely traversing cycles.
Things that don't work with structured cloneFunction
objects cannot be duplicated by the structured clone algorithm; attempting to throws a DataCloneError
exception.DataCloneError
exception.lastIndex
property of RegExp
objects is not preserved.Array
ArrayBuffer
Boolean
DataView
Date
Error
types (but see Error types below).Map
Number
Object
objects: but only plain objects (e.g., from object literals).symbol
.RegExp
: but note that lastIndex
is not preserved.Set
String
TypedArray
For Error
types, the error name must be one of: Error
, EvalError
, RangeError
, ReferenceError
, SyntaxError
, TypeError
, URIError
(or will be set to "Error").
Browsers must serialize the properties name
and message
, and are expected to serialize other "interesting" properties of the errors such as stack
, cause
, etc.
AggregateError
support is expected to be added to the specification in whatwg/html#5749 (and is already supported in some browsers).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4