Subnavigation

ECMAScript 5 and WebKit/JavaScriptCore

Today it's exactly one month since the press release stating that ECMA-262 5th edition (ES5) has been approved. (Yeah, that's just a random coincidence.) What's changed since the 3rd edition? Quoting the spec itself (actually, it's only the "Final final final final draft" according to the PDF document title :) ):

The [fifth edition of ECMAScript] codifies de facto interpretations of the language specification that have become common among browser implementations and adds support for new features that have emerged since the publication of the third edition. Such features include accessor properties, reflective creation and inspection of objects, program control of property attributes, additional array manipulation functions, support for the JSON object encoding format, and a strict mode that provides enhanced error checking and program security.

Mark Caudill gives a good 10000-feet overview of the new features. John Resig goes into more detail about Objects and properties and strict mode and more.

Here's my attempt at an overview of the ES5 implementation status in WebKit/JavaScriptCore (JSC).

Features implemented in JavaScriptCore

This is stuff that's already in WebKit trunk. I've included links to relevant Bugzilla tasks in case you'd like more information (e.g. have a look at the patches).

  • "Array extras": Array.prototype.{indexOf,lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight}:
    These have been in JSC for years. I'm not sure how conformant the implementations are, though.

Features not implemented in JavaScriptCore

  • Strict mode: I'm not aware of any work that's been done to support strict mode yet. It involves making the parser/compiler recognize the "use strict" directive and adapting execution according to the rules given in annex C of the ES5 specification. (The annex lists 20 restrictions/exceptions that apply to strict mode.)

Want to get involved or track the status?

Have a look at the open ES5 tasks at bugs.webkit.org. For creating new tasks, use component "JavaScriptCore", tag "ES5" and (optionally) summary prefix "[ES5]". In addition to implementing ES5 functionality or playing with it in your WebKit-based app, there are also opportunities to use that functionality within WebKit, such as in the test framework and the Web Inspector (whose front-end is written in JavaScript). For example, Object.getOwnPropertyNames() made it easy to resolve the long-standing issue of the Web Inspector console not auto-completing non-enumerable properties of built-in ECMA objects (https://bugs.webkit.org/show_bug.cgi?id=19119). And Object.getOwnPropertyDescriptor() could potentially be used to display detailed information about variables. I just love those new introspection capabilities! Finally it's possible to do things directly in JavaScript that you could only do with native (engine-specific) APIs before.

Happy ES5 hacking!


Blog Topics:

Comments