views:

145

answers:

1

Can someone point out the differences in implementation of ECMAScript 3rd edition in today's browsers? (Chrome, Safari, IE8, FF)

Are we safe when using ECMAScript 3 standards (and not the extensions that FF and IE have to JScript and JavaScript)?

+7  A: 

Well, of course there are implementation bugs, the most serious that I've had to deal with are on JScript, the Microsoft implementation of the standard, for example:

Identifier of FunctionExpressions should be accessible only in the inner scope of the function itself:

(function foo() {
  alert(typeof foo); // "function"
})();

alert(typeof foo);  // should be "undefined", on IE shows "function"

The bug is present on all current IE versions, it has just been fixed on IE9 Previews.

And actually is even worse, it creates two function objects, for example:

var foo = function bar() {};

if (typeof bar != 'undefined') { // the case of IE
  alert(foo === bar); // false!!!
}

Another well known JScript bug is the "DontEnum Bug", if an object in its scope chain contains a property that is not enumerable (has the { DontEnum } attribute), if the property is shadowed on other object, it will stay as non-enumerable, for example:

var dontEnumBug = {toString:'foo'}.propertyIsEnumerable('toString');

It will evaluate to false on IE, this causes problems when using the for-in statement, because the properties will not be visited.

JScript is the implementation that has the largest number of problems -although the IE9 implementation is getting really way better-.

Recommended article:

CMS
http://stackoverflow.com/questions/3663775/object-name-same-a-function-name/ Your answer to that question would make a nice addition to this. The FunctionStatement part at least.
CD Sanchez
Nice examples. If you (or someone else) has more articles highlighting ecmascript 3 implementation differences in browsers send them :)
AlfaTeK