4 ms·
Yes! Thank you. I agree the question is as you pose it -- why use `var`, ever?
by serve_yay 11y ago
Yes! Thank you. I agree the question is as you pose it -- why use `var`, ever?
- deleted 11y ago[deleted]
- benaiah 11y agoI believe the parent comment was referring to using “let” instead of “var” - “let” supports reassignment.
- Animats 11y ago"let", of course, is a retrofit to Javascript. So was "var". In the early days of Javascript, before "strict mode", few people declared anything and most variables had global scope. It's really hard to get a declaration-free language right. Python was the biggest success to date.
- serve_yay 11y agoSorry, what I meant was more that since we have let, there isn't any good reason to use var anymore. I definitely don't advocate the thing in this article where he eliminates var usage by littering the code with IIFEs.
- chc 11y agoHuh? `var` was not retrofitted. I distinctly remember it being there since I started learning JavaScript, like around '96. It is true that a lot of people were slack about using it, but that's just laziness, not that it wasn't there.
- SeanLuke 11y agoLisp?