On a side note, I find crazy this obsessive-compulsive behavior to use `const` everywhere in modern JS codebase (even in Webkit now). It solves really no problem (I mean, Python, Ruby and almost all other programming languages are doing fine without preventing against variable reassignment, and we can still reassign function parameters and object properties in JS). So much brain power wasted on this useless thing. Al…
Immutability has been pretty hot of late, though still controversial. There are several popular languages which encourage or even force immutability (Elixir, Clojure). What sold me on the idea was Rich Hickey's talk, "The Value of Values": https://www.youtube.com/watch?v=-6BsiVyC1kM I look at it as mostly a safety net: I'd rather use const by default, unless I have a good reason to be able to mutate the variable. (To…
const arr = ['foo'];
arr[0] = 'bar';
assert(arr[0] === 'bar'); // !!!
Something like that would make sense though IMHO:
const PHI = 1.618;
I don't get how JS is designed really, they try to solve a bad design (`var`) but they introduce another bad design (`const`) and they make things even messier. Many devs ship JavaScript thought TypeScript these days, so I hope Microsoft can clean this mess one day.