4 ms·
There are very few places where you ever need to use let or var. const is solving important issues - it has lexical scope instead var function scope - it d
by Chyzwar 7y ago
There are very few places where you ever need to use let or var. const is solving important issues
- it has lexical scope instead var function scope
- it does not hoist like var
- it prevents accidental reassignment
Accidental reassignment happen more often in JS because of non-lexial scoping, weakly typed and async functions. Also, both Ruby and Python are "strongly typed" as opposed to weakly typed Javascript.
- olliej 7y agoLet has lexical scope. I’ve always thought const was something of a mid feature, as it doesn’t generally do what people think. He’ll back when Opera was an actual browser engine it just used const as an alias for var.