←back to thread

498 points azhenley | 1 comments | | HN request time: 0.381s | source
Show context
mcv ◴[] No.45771788[source]
I use Javscript mostly. Or Typescript actually, these days. I remember when ES2015 introduced `let` because `var` had weird scoping issues. But ever since, I barely use either of them. Everything is `const` these days, as it should.
replies(3): >>45771959 #>>45772006 #>>45772055 #
1. LogicHound ◴[] No.45772055[source]
`var` doesn't have weird scoping issues, it just different than other languages. `var` is function scoped, thus all var declarations are hoisted to the top of the function during execution.

This is why the single var pattern used to be recommended.