0
Using keyword var in js
I want to ask, what is purpose of using keyword var before variable name, when it works same way without the keyword. I use var always when I declare a variable. But I had found a code, where inside for statement had been iteration variable used without the var keyword and it confused me. Thanks for answers! (pardon my english, Iâm not native speaker)
1 Answer
+ 3
Many new browsers are smart and can read code with a few things missing. However, officially you must use var, otherwise the code won't run in old browsers and may cause subtle errors even in new browsers.