DEV Community

Discussion on: Is`let` the new `var` in Javascript?

Collapse
 
rubyrubenstahl profile image
Ruby Rubenstahl

Personally I used const wherever possible. I use let where I need mutability, but find that its often a sign that I need to rethink what I'm doing, and I pretty much pretend that var doesn't exist.

Both hoisting and the fact that var is function scoped rather than block scoped adds a lot of unnecessary complexity to reasoning about my code. let and const make code much less ambiguous.

I've been seriously coding in JS pretty much since ES6 became mainstream and I have not once found a time when I needed to use var to do anything I needed to do.