April 2018
Intermediate to advanced
284 pages
5h 46m
English
| Tip 8 | Avoid Push Mutations with the Spread Operator |
In this tip, you’ll learn how to avoid array mutations by creating new arrays with the spread operator.
As you’ve just seen, mutations can have unexpected consequences. If you change something in a collection early in the code, you can create a bug much deeper. Mutations may not always cause major headaches, but they do have that potential, so it’s best to avoid them when possible. In fact, some popular JavaScript libraries (such as Redux) won’t allow functions with any mutations at all.
Plus, a lot of modern JavaScript is functional in style, meaning you’ll need to write code that doesn’t contain side effects and mutations. There’s a lot to be said about functional JavaScript, more than what ...
Read now
Unlock full access