Created
September 30, 2021 14:21
-
-
Save jmaicaaan/45bc11b86253267b88e6c0215bb1f150 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let y = 3; | |
| /** | |
| * The `sum` function is accessing the global variable `y` to compute for the sum | |
| */ | |
| const sum = (x) => x + y; | |
| /** | |
| * Here we are mutating the state of the variable `y` to `6` | |
| * which means that the computation of `sum` will now be different | |
| * This makes the `sum` function harder to understand and predict | |
| */ | |
| y = 6 | |
| const six = sum(3); | |
| console.log('six', six); // 9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment