I think Muhammad brings up some solid points here as to why you wouldn't want to use var. However, I don't agree with the author's notion that var should never be used. In fact, I'd argue that using var in the early stages of learning JavaScript will make the concept of declaring, changing, and working with variables easier to understand.
Chris Ferdinandi, a vanilla JavaScipt expert, has a nice explanation on why he doesn't use let or const in his projects: gomakethings.com/why-i-dont-use-le...
His reasoning: let and const aren't as backwards compatible as var, they can't be polyfilled, and trying to determing which type to use adds unnecessary cognitive overhead (especially for beginners).
I think Muhammad brings up some solid points here as to why you wouldn't want to use
var
. However, I don't agree with the author's notion thatvar
should never be used. In fact, I'd argue that usingvar
in the early stages of learning JavaScript will make the concept of declaring, changing, and working with variables easier to understand.Chris Ferdinandi, a vanilla JavaScipt expert, has a nice explanation on why he doesn't use
let
orconst
in his projects: gomakethings.com/why-i-dont-use-le...His reasoning:
let
andconst
aren't as backwards compatible asvar
, they can't be polyfilled, and trying to determing which type to use adds unnecessary cognitive overhead (especially for beginners).I totally agree with you. For a beginner, using
var
can be a good thing to understand working with variables.