Should host objects be able to have [[Class]] "Function", "Array" etc.?

Garrett Smith dhtmlkitchen at
Wed Nov 19 20:43:38 PST 2008

On Wed, Nov 19, 2008 at 11:28 AM, Brendan Eich <brendan at> wrote:
> On Nov 19, 2008, at 6:08 AM, Maciej Stachowiak wrote:
>>> I also don't see a problem with David-Sarah's suggestion of forbidding
>>> host objects from having [[Class]] "Function". Most places in the spec care
>>> only about whether something is callable (has a [[Call]] property), not
>>> whether it has [[Class]] "Function".
>> It seems arbitrary to me that functions implemented in native code
>> ("internal functions" in ECMA-262 terms) that are part of the ECMAScript
>> spec must have the [[Class]] "Function", but any that are not specified
>> there (and are perhaps specified elsewhere) would be required not to have
>> [[Class]] "Function". Why should Math.random be required to have [[Class]]
>> "Function", but document.getElementById or Math.myImplementationExtension be
>> required not to? Do you really think it makes sense to determine whether
>> something is a function by whether it is mentioned in the ECMAScript spec?
> That's silly, not only because of inclusion or location in spec being
> immaterial, but also because of gratuitous differences between host and
> native implementations even assuming the partitioning between them is fixed
> forever.
> It does seem worth addressing the variation among browsers where IE's alert
> is not a function -- has typeof-type "object" -- while it is "function" and
> has [[Class]] "Function" by all measures in other browsers I'm familiar
> with. This is considered an IE misfeature, AFAICT.

yes, I would consider it as such.

I would also consider making a collection a callable object a poor
design decision.

What I'm talking about is things like:-


> The original Netscape 2 implementation I did in 1995 wrapped the same
> function clothing around native and "host" functions.
> Does anyone know of other DOM implementations that differentiate detectably
> between host and native functions? Excluding exceptional cases such as
> Mozilla's LiveConnect proxy objects that represent overloaded Java methods,
> e.g.

Some versions of Opera will return "object" for some host objects that
implement [[Call]]; other versions return "function"

javascript:var f = document.forms; f(0); alert(typeof f);

Opera 9.5, IE:
Safari 3:


javascript:var f = document.all; f(0); alert(typeof f);
Opera 9.5, Safari 3:


Error (Standards Mode)

A native object that implements [[Call]] is supposed to return
"function". That is mostly true, with the exception of regexp in FF.
With a host object that implements call, the result cannot be


>> (Note also that Math.random has [[Class]] "Function" but not a "prototype"
>> property.)
> Yeah, that's something I missed in ES1 days, which must have come from
> JScript. The original Netscape JS implementation then, and SpiderMonkey
> still,  both give native functions .prototype properties (bug
> /be
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at

More information about the Es-discuss mailing list