3 ms·
The best option is to avoid everything that is not part ECMAScript 262, and even programming according to the spec you maybe at some point some inconsistencies.
by pdelgallego 16y ago
The best option is to avoid everything that is not part ECMAScript 262, and even programming according to the spec you maybe at some point some inconsistencies.
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/
- pdelgallego 16y agoI 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();