[JavaScript] variable conflicts can be compiled using javascript.
In JavaScript, the following code is a valid program:
Var I = 0; var I = 1; alert (I );
The running result is pop-up window output 1,
It seems that there is no problem at all. However, in some programming languages such as Java and C, the following similar code is not a legal program:
Int I = 0; int I = 0;
Compilation fails. What's more, how about running it? Because variable I is repeatedly defined, and in JavaScript, even if variable I is repeatedly defined, there is no problem. This is the problem of static scope and dynamic scope. Static scope and dynamic scope are specific. Here we will not put the concept in a large section of compilation principles on a large scale, so we will feel dizzy.
In Javascript, even if variable I is repeatedly defined, there is no problem. Even if variable conflicts can also be compiled, what is the problem?
The problem is very big. As a result, errors in the following program are hard to be found:
For (var I = 0; I <1; I ++) {for (var I = 0; I <1; I ++ ){}}
In some programming languages such as Java and C, a prompt is displayed that variable I is repeatedly defined, because the calculated variable I in for should be written as j or another, but Javascript will not, after your webpage is opened, it will not be displayed below the browser: Then you will find that the special effects you need cannot be properly killed. Especially in the context of today's world-wide code, it is difficult for you to find that the code you write, conflict with the copied code.