JavaScript · Middle · Question 62 of 75

How does Object.assign(target, source) differ from { ...target, ...source }?

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.

Further reading

Problem with a question

JavaScript · Middle · question 62

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz