JavaScript · Middle · Question 62 of 75
How does Object.assign(target, source) differ from { ...target, ...source }?
- ✓Correct answer:
Object.assignmutatestarget(and triggers its setters); spread creates a new object - 2Spread copies deeply,
Object.assignshallowly - 3They are identical
Explanation
Both are shallow and copy only own enumerable properties. Use Object.assign({}, a, b) if you need a new object with the older API.