Tip 12: Update Information with Object Spread
Explore how to use the object spread operator to update and merge JavaScript objects more cleanly than Object.assign(). Understand its behavior in overwriting keys and avoiding mutations. This lesson helps you write modern, maintainable code by adopting a widely embraced syntax.
We'll cover the following...
We'll cover the following...
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.
Object spread operator
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 ...