Global.structuredClone
Prev: Global | Up: Global | Next: Number_isNaN
Rel: Global, JS Core Syntax & Types
Ref: MDN Web Docs — Global.structuredClone
Tags: #public #web #javascript #builtins #global #tier/core
Signature & Overview
structuredClone(value, options?)
Native deep clone supporting Date, Map, Set, RegExp, TypedArray, and circular references.
Notes & Pitfalls
- Built-in deep clone: Handles nested objects, arrays,
Date,Map,Set,RegExp,ArrayBuffer, and circular references. - Cannot clone functions, DOM nodes, or class prototypes (throws
DataCloneError).
Example
const orig = { tags: new Set(["js"]), nested: { count: 1 } };
const copy = structuredClone(orig);
copy.nested.count = 99;
console.assert(orig.nested.count === 1 && copy.tags.has("js"));
Linked from
Related notes
- tuts/javascript/builtins/Global/Number_isNaN Linked here; links to this page; shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Global Linked here; links to this page; shared tags: #builtins, #global, #javascript, #web
- tuts/javascript/tutorials/core_syntax_and_types Linked here; shared tags: #javascript, #web
- tuts/javascript/builtins/Global/encodeURIComponent shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Global/globalThis shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Global/isNaN shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Global/parseInt shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Global/queueMicrotask shared tags: #builtins, #global, #javascript, #tier, #web
- tuts/javascript/builtins/Array/at shared tags: #builtins, #javascript, #tier, #web
- tuts/javascript/builtins/Array/filter shared tags: #builtins, #javascript, #tier, #web