Re:A re-introduction to JavaScript
by pdelgallego on Sunday July 18, 2010 @04:33AM
(#1525435)
I mean
===
if (true) {
function foo(){ return 1; }
} else {
function foo(){ return 2; }
} foo();
===
if (true) {
foo = function (){ return 1; }
} else {
foo = function (){ return 2; }
} foo();
Check out the sputnik test project[1] to see what is working in the different VM.
An easy example of inconsistency : If you read the specs you will find that FunctionDeclarations are only allowed to appear in Program or FunctionBody. Syntactically, they can not appear in Block s. But because the specs allowed extensions you can find that Mozilla/rhino/spidermonkey implement a different way that Webkit/V8
run this code in firebug and in the inspector a you will see that produce two difference.
<code><pre> if (true) { function foo(){ return 1; } } else { function foo(){ return 2; } } foo(); </pre><code>
Indeed things are not that bad, because is easy to avoid it.
var foo; if (true) { foo = function foo(){ return 1; }; } else { foo = function foo() { return 2; }; } [1]sputnik.googlelabs.com/