CodeNewbie Community 🌱

Discussion on: Why shouldn't I use "var" in JavaScript?

Collapse
 
weswedding profile image
Weston Wedding

As Isaac touched on, it can be easier to understand and reason through code that uses let and not var, which I consider to be one of the most important aspects of writing code. JavaScript's Hoisting is very unintuitive to many people!

There can also be specific circumstances where let and var have performance differences in some Browsers and maybe even some versions of NodeJS. However, this level of min/maxing your coding is not something you should worrying about unless you are writing a complex library that needs to a lot of heavy, repetitive tasks like processing large quantities of images or handling a high bitrate datastream from a stock exchange. Some early browser implementations of let and const were signficantly slower than var, but those were bugs that got fixed.