well, it's not true really. In the following example x will have global scope and y will be local to its function:
x=2;
function test() {
y = x + 3;
}
--
That's quite wrong. Both y and x will be global scope. You just declare y with "var" in order for it to be a function scope variable.
The major problem with Javascript is that it is a hodge-podge of different languages mixed together where the semantic syntax is "C-like"; so you get a bunch of programmers who are arguing over the logic of scope when they really don't understand the rules of the language well enough.
well, it's not true really. In the following example x will have global scope and y will be local to its function:
x=2; function test() { y = x + 3; }
--
That's quite wrong. Both y and x will be global scope. You just declare y with "var" in order for it to be a function scope variable. The major problem with Javascript is that it is a hodge-podge of different languages mixed together where the semantic syntax is "C-like"; so you get a bunch of programmers who are arguing over the logic of scope when they really don't understand the rules of the language well enough.