Skip to content

Instantly share code, notes, and snippets.

@galvao
Created April 13, 2020 05:50
Show Gist options
  • Select an option

  • Save galvao/e51a04484fd56c63cbe7a8886926c613 to your computer and use it in GitHub Desktop.

Select an option

Save galvao/e51a04484fd56c63cbe7a8886926c613 to your computer and use it in GitHub Desktop.
JavaScript's isue with "constants"(sic)
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