The JavaScript variable declares the difference with Var and without Var:
In JavaScript, declaring variables can either use VAR or not using Var, here's a look at the difference between the two.
I. Scope differences:
Variables declared without Var are scoped globally regardless of whether they are declared inside the function.
Variables declared with VAR are global if declared outside of the function, and local variables are declared inside the function.
code example:
<type= "Text/javascript">var A; function Fun () { var b; C=ten;} </ Script >
In the above code, the scope of A and C is global, and the scope of B is local.
Two. Is it possible to delete using Delete:
variable declarations, creation properties, and properties in each JavaScript have flags that illustrate their properties----such as read-only (ReadOnly) non-enumerable (Dontenum) non-deleting (dontdelete), and so on. a variable declared without Var, which is exactly the property of the Window object, can be deleted by the delete, and the variable declared with VAR has a non-deleted attribute, so it cannot be deleted by delete.
For more information, refer to the delete operator section of JavaScript .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=8177
For more information, refer to: http://www.softwhy.com/javascript/
JavaScript variable declaration with Var and without var difference