there are 3 explicit ways a variable can be declared in javascript.
var
let
const
var
var is the grandfather of declarations in js....
For further actions, you may consider blocking this person and/or reporting abuse
In higher development, especially real world jobs. We don't use
varat all. In fact, it's a buzz word when you come to interview and usevarinstead ofletandconst. I reccommend removevarcompletely when you have learned ES6. Just because It's a industry standard already.Like I join the interview with my head of engineering one time to interview a girl. And she is not very familiar with javascript and use
varinstead ofletandconstlike it's a BUZZ right away there. Eventually we didn't fail her because she usevarbut we did fail her because her lacking of understanding of javacsript.Agreed, in my experience as well using
letmakes sense almost all of the time.There is only one case in favor of
vari.e. to use it when you intentionally want to make a variable scoped to the function instead of any block( better done with let if you ask me)Still, the purpose of article is to provide a comprehensive view of what all is possible in JS and more importantly tell what are the implications of using each one here.
And as you pointed out it being a buzz word for interview, can lead to some tricky questions, around using
varwithclosures- so always good to have an understanding about how it behaves and why it does so.