Note Built-in deep clone that handles Dates, Maps, Sets, RegExps, ArrayBuffers, circular references. Cannot clone functions, DOM nodes, or Error objects.
Frequently asked questions
How does JavaScript handle structuredClone?
JavaScript covers this with 3 copy-ready snippets on this page. The "Deep Cloning Arrays" snippet in JavaScript uses `structuredClone(value)`.
Which code does the JavaScript example use?
The "Deep Cloning Arrays" snippet uses `structuredClone(value)`, from the Arrays section of the JavaScript cheat sheet.
What other JavaScript snippets are shown for "structuredClone"?
Besides "Deep Cloning Arrays", this page also shows "Deep Cloning Objects", "structuredClone()".
Is there anything to watch out for?
Yes. For "Deep Cloning Arrays": structuredClone handles nested objects, arrays, Maps, Sets, Dates, RegExps, and more. Does NOT clone functions, DOM nodes, or prototypes.