Static Array and String Generics and Host Objects (ATTN IE Team)

Garrett Smith dhtmlkitchen at
Fri Dec 4 13:48:42 PST 2009

Static Array and String Generics was an ES4 proposal[0], and is
implemented in Mozilla JavaScript 1.6[1].

What are the plans for including Array and String Generics in future
revision of ES?

There is no new syntax needed to support this. Scripts today can be
compatible by adding:-

if(!Array.slice) {
    Array.slice= function( arrayLike, start, end ) {
        return arrayLike,
          start||0, end||arrayLike.length);

However, there is a remaining problem there: No guaranteed behavior
with Host object and Errors in IE. Example:
  javascript:alert(   [] document.childNodes ) );

Error in IE8: "JScript Object Expected".

It would be best for IE to use Native object for Host objects. That
way, unwanted surprises like the above error should be done away with.

Array and String generics are useful for non-array objects.

The outcome of [] should be determinable. It is up to
public-script coord to define what happens when a Host object is used
in an Array.

Brendan's 7-month-old message[2] asking for IE to comment on Array
generics with host object, should be proactively addressed.

There are open bugs for Webkit[3] and Chrome[4] for implementing Array
generics At the time that I  filed the webkit bug, I was under the
impression that it was on its way to being standardized. I do not see
that happening.

1) ES Harmony standardize Static Array and String generics
2) The IE team use Native object for Host object collection


More information about the es-discuss mailing list