Menu

1 / 4

structuredClone Copies Your Data. It Doesn’t Untangle It.

JavaScript in Plain English - Medium·Ferid Brković·about 6 hours ago
#JLyTtAVL
Reading 0:00
15s threshold

Member-only story

structuredClone Copies Your Data. It Doesn’t Untangle It.

Ferid Brković

4 min read4 hours ago

Press enter or click to view image in full size

Why editing one address can change another inside a deep copy — and how to make the draft match your form’s behavior.

You deep-clone an order before opening an edit form. The original stays untouched. Then you change the billing city, and the shipping city changes too.

The clone worked. The assumption about what it would separate did not.

This can happen when billing and shipping point to the same address object. structuredClone creates a new object graph, but it preserves that shared relationship inside the copy. If your form expects independently editable addresses, a deep copy alone does not establish that contract.

Two fields, one address

Here is a complete example using ordinary objects and an array.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.