3 ms·
Yeah that's a problem. I thought you could get proper scoping by writing "var" in front of everything?
by krichman 14y ago
Yeah that's a problem. I thought you could get proper scoping by writing "var" in front of everything?
- mercurial 14y agoThat's function scope, not block scope. You can use the "let" keyword to get block scope since Javascript 1.7.
- PommeDeTerre 14y agoIt still took over a decade to get what should have been available from the very beginning. That's a pretty serious problem that repeats time and time again with JavaScript.
- deleted 14y ago[deleted]
- mercurial 14y agoOh, definitely. But I haven't found it overly problematic in practice. I'll point out that Python, a language much more appreciated than Javascript on HN, has no scope smaller than function scope. Which is mostly fine as long as you stick to small functions, which you should anyway.