Web APIs

structuredClone()

Try the free JavaScript compiler

Host API cloning a supported value graph, including cycles. Transfer options can move supported transferable objects. Functions and unsupported values fail; custom prototypes and property descriptors are not generally preserved. Not part of ECMAScript core.

Formal Syntax & Structure

javascript syntaxjavascript
structuredClone(value, [options])

Parameters & Attributes

NameTypeDescription
valueAnyStructured-cloneable value.
optionsObjectOptional transfer list.

Return Value

Any

Cloned value.

Working Example

Example Snippetjavascript
const a={child:{n:1}};a.self=a;const b=structuredClone(a);b.child.n=8;console.log(a.child.n,b.self===b);
JavaScript Reference