Browse Source

Fix object spread operator (#8378)

Object spread operator performs shallow copy of object's arguments, so it should be placed before new properties are assigned.
main
Mikhail Osher 8 years ago
committed by Dan Abramov
parent
commit
69162fc97a
  1. 2
      tutorial/tutorial.md

2
tutorial/tutorial.md

@ -226,7 +226,7 @@ var newPlayer = Object.assign({}, player, {score: 2});
// Now player is unchanged, but newPlayer is {score: 2, name: 'Jeff'}
// Or if you are using object spread, you can write:
// var newPlayer = {score: 2, ...player};
// var newPlayer = {...player, score: 2};
```
The end result is the same but by not mutating (or changing the underlying data) directly we now have an added benefit that can help us increase component and overall application performance.

Loading…
Cancel
Save