LearnFrenzy
Sign in Take a free test

Spread and Rest Operators · Spread and Rest MCQ · Question 11

Spread vs Object.assign Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links