April 2018
Intermediate to advanced
284 pages
5h 46m
English
| Tip 11 | Create Objects Without Mutations Using Object.assign() |
In this tip, you’ll learn how to update an object without mutations, using Object.assign().
In the previous tip, you took a quick look at objects and got rules for when they offer distinct advantages over other collections. Still, you need to be careful when using them because they can leave you open to the same problems with mutations and side effects that you saw in arrays. Casually adding and setting fields on objects can create unseen problems.
Consider a very common problem. You have an object with a number of key-values pairs. The problem is that the object is incomplete. This happens often when you have legacy data and there are new fields, or you are getting data from an ...
Read now
Unlock full access