postMessage() or when storing objects with IndexedDB. It builds up a clone by recursing through the input object while maintaining a map of previously visited references in order to avoid infinitely traversing cycles.
Things that don't work with structured clone
Functionobjects cannot be duplicated by the structured clone algorithm; attempting to do so will throw a
- Attempting to clone DOM nodes will likewise throw a
- Certain parameters of objects are not preserved:
RegExpobjects is not preserved.
- Property descriptors, setters, and getters (as well as similar metadata-like features) are not duplicated. For example, if an object is marked read-only using a property descriptor, it will be read-write in the duplicate, since that's the default condition.
- The prototype chain does not get walked and duplicated.
|All primitive types||However, not symbols|
|ArrayBufferView||This basically means all typed arrays like Int32Array etc.|
|Object||This just includes plain objects (e.g. from object literals、FormData objects)|