News for hackers. Stuff that matters.
Re:How necessary are var, let, and const? by moogly on Monday June 01, 2015 @12:29PM (#9639925)
I found this article's premises and findings rather pointless, and kept on wanting the author to instead verify the premise "are there actually valid uses of 'var' now that 'let' exists?" (I haven't found any yet, and I'd like to know if I'm wrong). But maybe I'm too much of a pragmatist rather than an academic, so I suppose it wasn't written for me.
Re:How necessary are var, let, and const? by serve_yay on Monday June 01, 2015 @12:33PM (#9639956)
Yes! Thank you. I agree the question is as you pose it -- why use `var`, ever?
Re:How necessary are var, let, and const? by Animats on Monday June 01, 2015 @01:32PM (#9640519)
"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.

Re:How necessary are var, let, and const? by chc on Monday June 01, 2015 @02:20PM (#9640898)
Huh? `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.
Re:How necessary are var, let, and const? by serve_yay on Monday June 01, 2015 @02:14PM (#9640862)
Sorry, 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.
Re:How necessary are var, let, and const? by SeanLuke on Monday June 01, 2015 @11:44PM (#9643718)
Lisp?
[deleted]
Re:How necessary are var, let, and const? by benaiah on Monday June 01, 2015 @01:04PM (#9640246)
I believe the parent comment was referring to using “let” instead of “var” - “let” supports reassignment.
Re:How necessary are var, let, and const? by jsnoble on Monday June 01, 2015 @02:12PM (#9640850)
Before ES6 im curious did you always need blocked scoped variables? Of course we used iife's when we needed to but how often did we need to do that compared to the times we used regular variables. Is it always worth the extra overhead to enforce everything being blocked scoped? What about times that we needed to alter something outside the scope? whether or not thats always a good idea is another discussion but there are valid uses. I remember people were getting all worked up over functional expressions vs declarations saying expressions were 'the one true way' since it more closely resemebles how the compiler reads it. As babel shows let and const are just var's with extra overhead. Dont get me wrong let and const are in the right direction but they are not 'the one true way'