Tip 12 Update Information with Object Spread

In this tip, you’ll learn how the object spread operator gives you all the advantages of Object.assign() with reduced syntax.

You saw in the previous tip how you can use Object.assign() to make copies of objects and how you can overwrite object values with new values from another object. It’s a great tool that has a lot of value. But, wow—it’s ugly.

The spread operator was such a popular addition in ES6 that similar syntax is being introduced for objects. The object spread operator is not officially part of the spec, but it’s so widely used that it will likely be adopted in the future. You can check out the proposal on github.[12]

Get Simplifying JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.