I would say it's better to use "var" in most situations.
Local variables are always faster than the variables in global scope.
If you do not use "var" to declare a variable, the variable will be in global scope.
For more information, you can search "scope chain javascript" in Google.
Using
Local variables are always faster than the variables in global scope.
If you do not use "var" to declare a variable, the variable will be in global scope.
For more information, you can search "scope chain javascript" in Google.
Using
var
is always a good idea to prevent variables from cluttering the global scope and variables from conflicting with each other, causing unwanted overwriting.
Comments
Post a Comment