JavaScript · Junior · Question 21 of 75
What does const copy = { ...original } do?
- ✓Correct answer: A shallow copy: nested objects remain shared
- 2A deep copy of all nested objects and arrays
- 3A reference to the same object, like
const copy = original
Explanation
Spread copies only own first-level properties. If original.address is an object, it's shared by both copies. structuredClone gives a deep copy, but it doesn't copy functions or DOM nodes.