Web APIs
structuredClone()
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
| Name | Type | Description |
|---|---|---|
| value | Any | Structured-cloneable value. |
| options | Object | Optional 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);