CKTIS / JavaScript
structuredClone(): deep copying and data transfer
structuredClone() copies supported data structures, including nested objects and cycles. The transfer option moves resources instead of copying them; not every value type can be cloned.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
structuredClone(value)
structuredClone(value, { transfer: [transferable] })structuredClone(value, options) synchronously clones supported data. It preserves cycles and repeated references to the same object within the copy. Supported types include plain objects, arrays, Date, Map, Set, and ArrayBuffer.
Where cloning a SharedArrayBuffer is permitted, the clone is a distinct object backed by the same memory as the original. Writes through either buffer can be observed through the other without using the transfer option.
It is not a universal way to copy class instances: custom prototypes, property descriptors, and private fields are not preserved. For ordinary objects, it copies own enumerable string-keyed properties; reading getters can execute code. Functions and Symbol values encountered during serialization cause a DOMException named DataCloneError.
The { transfer: [buffer] } option transfers an ArrayBuffer resource instead of copying its bytes. The original buffer becomes detached and its byteLength becomes 0. The transfer list does not add resources to the result: they must be reachable from value for the result to provide access to them.
This is an HTML-standard API, not a feature introduced in a particular ECMAScript edition. The standard's compatibility table lists Chrome 98+, Firefox 94+, and Safari 15.4+. Check typeof structuredClone === "function" in the target environment; Node 24 in a repository does not establish browser support.
Examples
const original = { items: [{ count: 1 }] };
original.self = original;
const copy = structuredClone(original);
copy.items[0].count = 2;
console.log(original.items[0].count, copy.items[0].count);
console.log(copy !== original, copy.self === copy);
const buffer = new ArrayBuffer(4);
const moved = structuredClone({ buffer }, { transfer: [buffer] });
console.log(buffer.byteLength, moved.buffer.byteLength);Result
1 2 true true 0 4
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.