ECMAScript 3 and beyond

The web has become the primary global computing platform tying together hundreds of millions of sites. In the eight years since the release of the ECMAScript Language Specification 3rd Edition (ES3), ECMAScript (commonly known as JavaScript™ or JScript ™) has grown in importance as one of the key technologies of the web.

The specification of ECMAScript has been stable for eight years. In many ways, this stability was probably an essential enabler for the emergence and broad adoption of Ajax technologies. However, today’s ES3 standard does not capture all the de facto compatibility conventions reached by eight years of this stability - the compatibility so essential to the success of rich web applications. For rich web applications to be successful, JavaScript must function identically on all browsers. The developer of a JavaScript-based web application does not get to choose what implementation will run their application; the user implicitly chooses that when they choose their preferred browser. Strong implementation conformance, then, across browser-based implementations is fundamental.

Let me give you a few examples of the lack of such conformance:

Did you know that Custom properties that shadow [[DontEnum]] properties on Object.prototype are not enumerated using for-in in IE? Consequently, it is not possible to transfer them from one object to another using for-in. Consider the following script where toString is shadowed on cowboy.

<script>

function cowboy() {

  this.toString = function () { return "cowboy"; }

  this.shoot = function () { return "bang!"; }

}

var p = new cowboy();

document.write("Enumerable properties:");

for (var i in p) {

  document.write(" ", i);

}

var res = p.propertyIsEnumerable("toString");

document.write("<br/>propertyIsEnumerable(\"toString\"): ", res);

res = p.hasOwnProperty("toString")

document.write("<br/>hasOwnProperty(\"toString\"): ", res);

</script>

How about the case where FireFox implements additional properties (and that could cause unexpected results)?

<script>

var x = {};

x.__proto__ = 3;

document.write(x.__proto__);

</script>

Try these on your browser and see what happens.

The point is that JavaScript developers shouldn’t have to detect and workaround such issues. JavaScript should work the same across all implementations. We believe this is the first step in making JavaScript better.

To make it possible to achieve such implementation conformance, the first step is knowing where the divergences are. We in the JScript team are looking into where various browser based implementations diverge, where our engine is incorrect in its interpretation of the specification, what if any de facto compatibility conventions have been reached, and the value of codifying such conventions into the standard. We’ve published the first draft of JScript Deviations from ES3 as a starting point.

In upcoming posts I will touch briefly on issues that we are looking at keenly and that we hope will make the life of the web programmer easier. If you would like some specific topic covered, please do let us know.

- Pratap Lakshman, JScript