Created
April 13, 2020 05:50
-
-
Save galvao/e51a04484fd56c63cbe7a8886926c613 to your computer and use it in GitHub Desktop.
JavaScript's isue with "constants"(sic)
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
| const FOO = 2; | |
| const BAR = {"c": 42}; | |
| const BAZ = [12, 14]; | |
| BAR.e = 43; | |
| console.log(BAR); | |
| BAZ.push(16); | |
| console.log(BAZ); | |
| /** | |
| * The following line, as expected, throws an error, as it should happen on lines 5 and 7. I realize this is by design, but I can't accept it. | |
| * | |
| * Bottom line: const should only work with scalar values. | |
| */ | |
| FOO = "xyz"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment