structuredClone Limitations
What you'll learn: You'll discover what structuredClone cannot copy, even though it handles deep cloning better than JSON methods.
While structuredClone is powerful for deep cloning, it has important boundaries. It uses the "structured clone algorithm" which was designed to safely copy data across different JavaScript contexts (like between web workers). Because of this, it cannot clone certain JavaScript features that don't translate well or have special behaviors.
What structuredClone Cannot Copy
Functions — Functions contain executable code and closures that can't be safely serialized. If you try to clone an object with a method, structuredClone will throw an error.
Symbols — Symbol properties are completely ignored during cloning. They simply won't appear in the cloned object.
DOM Nodes — Elements from the web page (like a <div> or <button>) can't be cloned. These have complex browser-internal state.
Prototypes — The cloned object will have Object.prototype as its prototype, even if the original had a custom prototype chain. You lose the prototype relationship.
Think of It This Way
Imagine structuredClone as a photocopier that only handles paper documents. It can copy complex nested folders of papers (deep data structures), but it can't copy a phone (function), a building key (symbol), a plant (DOM node), or the filing system itself (prototype). It creates plain, data-only copies.
When This Matters
If your objects contain only plain data (strings, numbers, arrays, nested objects, Dates, Maps, Sets), structuredClone works perfectly. But if you're cloning objects with methods, custom prototypes, or special properties, you'll need a different strategy or accept that those features won't survive the clone.
Key Takeaway: structuredClone is limited to copying pure data structures—it cannot clone functions, symbols, DOM nodes, or preserve prototype chains.