var in many languages are more common, in the end what is Var, how to apply, the following is the author's Common JavaScript, C # for VAR description:
var is shorthand for variable (variables, variable). In a variety of computer programming languages, VAR is used as a keyword to define variables, and it can be seen in some operating systems.
varA=Ten;//correctA=Ten;//correctin JavaScript, both of these methods are the correct way to define variables. This is explained in Microsoft's Script56.chm: Although not secure, it is legitimate to omit the Var keyword from the declaration statement. At this point, the JScript interpreter gives the variable global scope visibility. When a variable is declared at the procedure level, it cannot be used for global scope, in which case the variable declaration must use the VAR keyword. From the above description, the two definition methods are treated to distinguish between the following two cases: ⒈ in a process level (that is, within the definition of a function, whether it is functions, or classes) anywhere, including in a block ( for, while,if... ), when defining a variable, using the var definition, this variable only works at the process level, and vice versa, as a global variable. ⒉ when defining variables outside the procedure level, a global variable is defined regardless of whether or not to ignore var. From this point of view, JS and other languages have a different place, the scope of the variable is not "{}" as the boundary, but to"function () {}"as a boundary, and it is easy to define global variables within the process. If you do not pay attention to this problem, it is easy to produce unpredictable errors. For the use of Var, my advice is to develop good habits: ⒈ at the beginning of the program, define global variables uniformly, ⒉ all variables are defined with Var;⒊ try not to use the same variable name in different procedures.
3.0= "ABCD" form, not the following form:var= "ABCD"; ⒉ once initialization is complete, it is no longer possible to assign values that differ from the initialization value type to the variable. ⒊var requirements are local variables. ⒋ using var to define variables is different from object, which is exactly the same as defining variables in terms of efficiency and using strongly typed methods.
A detailed description of the var keyword