Skip to content

Commit 91676a6

Browse files
Mikhail Oshergaearon
authored andcommitted
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.
1 parent 65f9d2a commit 91676a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/tutorial/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ var newPlayer = Object.assign({}, player, {score: 2});
226226
// Now player is unchanged, but newPlayer is {score: 2, name: 'Jeff'}
227227

228228
// Or if you are using object spread, you can write:
229-
// var newPlayer = {score: 2, ...player};
229+
// var newPlayer = {...player, score: 2};
230230
```
231231

232232
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.

0 commit comments

Comments
 (0)