Skip to content

Commit daf2d6c

Browse files
authored
Add caveats
1 parent 5d209da commit daf2d6c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,16 @@ console.log(newName); // ['Ryan', 'McDermott'];
553553
### Avoid Side Effects (part 2)
554554
Side effects could also occur from inside a function. In JavaScript, primitives are
555555
passed by value and objects are passed by reference. In the later case, we should be
556-
careful not to change any of these argument's properties. A possible solution would
557-
be to always clone the variable, edit it and return the clone.
556+
careful not to change any of these argument's properties.
557+
558+
A possible solution would be to always clone the variable, edit it and return the
559+
clone. There would be cases where you actually want to modify the input object
560+
and this should not be taken as a silver bullet. Furthermore, cloning big objects can
561+
be very expensive in terms of performance.
558562

559563
**Bad:**
560564
```javascript
561-
function userReducer(state, action) {
565+
function (state, action) {
562566
state.userProfile = action.payload;
563567
return state;
564568
}

0 commit comments

Comments
 (0)