Re:Modern Javascript: Everything you missed over the last 10...
by errantspark on Saturday May 15, 2021 @01:51PM
(#27167342)
Right but we have `let` now which solves that problem.
[ Parent
| on HN ]
Re:Modern Javascript: Everything you missed over the last 10...
by titzer on Saturday May 15, 2021 @04:21PM
(#27168633)
Not completely, `let` also has a weird temporal dead zone[1], which is basically a dynamic check.
[1] https://www.freecodecamp.org/news/what-is-the-temporal-dead-...
Re:Modern Javascript: Everything you missed over the last 10...
by IshKebab on Sunday May 16, 2021 @03:55AM
(#27171996)
That's a good thing, and I'm not sure what you mean about it being a dynamic check.
Re:Modern Javascript: Everything you missed over the last 10...
by titzer on Sunday May 16, 2021 @01:38PM
(#27175428)
It's a dynamic error if you access a let-bound variable before it is actually initialized. In most other languages that have lexically-scoped declarations, it simply would not be visible. So I think JS's choice is actually a regression.