Skip to content
uencoder

Structured Clone

The structured clone algorithm recursively copies object graphs (including circular references, Date, RegExp, Map, Set, ArrayBuffer) for cross-context transfer via postMessage.

Purpose

Stronger object copying than JSON.stringify, supporting circular references and more types; the serialization foundation of postMessage.

Mechanism

It recursively walks object properties copying values, supporting circular references (via a memo table), Date, RegExp, Map, Set, TypedArray, ArrayBuffer, Error, etc. Functions, DOM nodes, and Symbol properties are not supported.

Use cases

  • postMessage serialization
  • Object deep copy
  • Cross-context transfer

Related tools

References