@@ -505,7 +505,7 @@ function createTempFile(name) {
|
505 | 505 | ```
|
506 | 506 | **[⬆ back to top](#table-of-contents)**
|
507 | 507 |
|
508 |
| -### Avoid Side Effects |
| 508 | +### Avoid Side Effects (part 1) |
509 | 509 | A function produces a side effect if it does anything other than take a value in
|
510 | 510 | and return another value or values. A side effect could be writing to a file,
|
511 | 511 | modifying some global variable, or accidentally wiring all your money to a
|
@@ -550,12 +550,11 @@ console.log(newName); // ['Ryan', 'McDermott'];
|
550 | 550 | ```
|
551 | 551 | **[⬆ back to top](#table-of-contents)**
|
552 | 552 |
|
553 |
| -### Avoid Side Effects pt.2 |
554 |
| -Side effects could also occur from inside a function. In Javascript, function arguments |
555 |
| -are always passed by value except when they(functions) are passed reference values such as |
556 |
| -objects and arrays. In that case, we should be carefull not to change any of these |
557 |
| -argument's properties. A possible solution would be to always clone the variable, |
558 |
| -edit it and return the clone. |
| 553 | +### Avoid Side Effects (part 2) |
| 554 | +Side effects could also occur from inside a function. In JavaScript, primitives are |
| 555 | +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. |
559 | 558 |
|
560 | 559 | **Bad:**
|
561 | 560 | ```javascript
|
|
0 commit comments