4 ms·
let is obviously needed(devs like lexical scoping) but I found the whole var + let in the same language thing a bit confusing. The temptation to introduce yet a
by aikah 11y ago
let is obviously needed(devs like lexical scoping) but I found the whole var + let in the same language thing a bit confusing. The temptation to introduce yet another strict mode(to forbid var,and a few other constructs) is strong on this one.
- braythwayt 11y agovar vs. let in the same language is a consequence of designing the language by committee, requiring 100% backwards-compatibility, and forbidding the addition of new modes (which is a back-door way to introduce breaking changes, while requiring browser vendors to essentially support multiple versions).
- sebleblanc 11y agoThat behaviour is not exclusive to standards committees. The government and private companies do it all the time.
- CrossEye 11y ago"governments and private companies" certainly do not preclude committees. Quite to the contrary, in fact.
- sesutton 11y ago>The temptation to introduce yet another strict mode(to forbid var,and a few other constructs) is strong on this one. There is a proposal for that, coincidentally called "strong mode". https://docs.google.com/document/d/1Qk0qC4s_XNCLemj42FqfsRLp49nDQMZ1y7fwf5YjaI4/view https://docs.google.com/document/d/1Qk0qC4s_XNCLemj42FqfsRLp...
- seasoup 11y agoThat is not at all obvious to many long time JavaScript engineers. Having a variable scoped by block or by function works for me, having both in the language is a pain. I have seen some neat tricks that you can do with let in for loops, but nothing that has convinced me it's worth the cognitive overhead of figuring out is this variable a var or a let. My opinion is that if you use let, don't use var, and if you use var, don't use let. Either one on its own is fine, together they are just a mess.