4 ms·
>a couple of things that JavaScript got so incredibly correct: . . . Lexical scope natively without syntax or conventions What language of the last 28 years do
by hollerith 6y ago
>a couple of things that JavaScript got so incredibly correct: . . . Lexical scope natively without syntax or conventions
What language of the last 28 years doesn't "natively" lexically scope its variables?
- z3t4 6y agoJavaScript is different in that it use the function as the lexical scope rather then the angel brackets. This forces you to think about the code as functions, rather then blocks. And in turn helps you think of the code in three dimensions where time is one dimension, making it easier to understand code that runs asynchronously.
- z3t4 6y agoBecause people coming from other languages find this confusing the let (and const) keyword was specified (ES6/2015) for block/angel-bracket lexical scope. Whereas var is function scoped.
- icedchai 6y agoNot Javascript. If I forget a var or let, it's global.
- austincheney 6y agoStrict mode throws an error on implied globals. Use of modules forces strict mode.
- icedchai 6y agoAnd that's all "extra" syntax.