Question 11
Back to Exercise
What is the key difference between Object.assign(target, src) and { ...target, ...src }?
- A Object.assign mutates target (calling its setters); spread builds a new object Correct
- B Spread copies deeply; Object.assign copies shallowly
- C Object.assign skips undefined values
- D There is no difference
Correct Answer: Option A
Both are shallow and both let later values win. Object.assign writes into an existing object; spread never changes its inputs.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!