re: 🤔Pop Quiz! Which of these is an infinite loop? VIEW POST


Ha! That's a great illustration for why let is better than var :)

I actually did have a case where I had to use var once - but it was a really obscure hacky-case where I found myself actually wanting to leak the variable scope (because of how a third party library was behaving)... but! I quickly came to my senses and refactored the whole thing so I wouldn't have to do that.

I took more time to finish the feature - but I'm sure it was worth it 😅


I still have one use case for var - a browser's developer tools.
Often I need to quickly test an idea and I write
var foo = 'bar'
then after some thoughts I press arrow up on keyboard and change previous input to
var foo = 'baz'

With let I get Uncaught SyntaxError: Identifier 'foo' has already been declared and it always frustrating 😐


Oh yea, I use var in console for the same reason!

Code of Conduct Report abuse