re: Var and Function Scope In Javascript VIEW POST


i don't know why but a lot of people are using the var... not sure if i should still use it or not ? I'm learning javascript at the moment so i'm a little confuse.


Moving forward I would say, don't use var anymore. Ever since 2015, the industry has been moving away from it in favor of let and const. Any time you see var in the wild, it's probably old code examples that haven't been updated in a while. If you're confused when seeing examples online, you can mentally replace them with let. Hope that helps!

code of conduct - report abuse