Re:Modern Javascript: Everything you missed over the last 10...
by icedchai on Saturday May 15, 2021 @02:52PM
(#27167847)
Not Javascript. If I forget a var or let, it's global.
Re:Modern Javascript: Everything you missed over the last 10...
by austincheney on Saturday May 15, 2021 @03:22PM
(#27168073)
Strict mode throws an error on implied globals. Use of modules forces strict mode.
Re:Modern Javascript: Everything you missed over the last 10...
by icedchai on Saturday May 15, 2021 @03:53PM
(#27168400)
And that's all "extra" syntax.
Re:Modern Javascript: Everything you missed over the last 10...
by JoyrexJ9 on Saturday May 15, 2021 @04:01PM
(#27168474)
strict mode is the default in everything now and had been for many many years.
Re:Modern Javascript: Everything you missed over the last 10...
by icedchai on Saturday May 15, 2021 @05:14PM
(#27169093)
It isn't the default for a browser "<script>" tag.
Re:Modern Javascript: Everything you missed over the last 10...
by xigoi on Saturday May 15, 2021 @05:54PM
(#27169371)
It's the default for <script type="module">, which you should use anyway for anything serious.
Re:Modern Javascript: Everything you missed over the last 10...
by z3t4 on Saturday May 15, 2021 @02:46PM
(#27167807)
JavaScript 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.
Re:Modern Javascript: Everything you missed over the last 10...
by z3t4 on Sunday May 16, 2021 @05:21AM
(#27172400)
Because 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.
What language of the last 28 years doesn't "natively" lexically scope its variables?