[[Class]] Property of Host Object

Garrett Smith dhtmlkitchen at gmail.com
Fri Jul 16 21:54:20 PDT 2010

I have a question reqarding [[Class]] property as defined In ES5:

| The value of the [[Class]] internal property of a host object
| may be any String value except one of "Arguments", "Array",
| "Boolean", "Date", "Error", "Function", "JSON", "Math", "Number",
| "Object", "RegExp", and "String"

May it be something other than a string value? Or must it be a string value?

Why must a host object's class be none of the built-in classes listed?
Implementations don't agree; when calling `Object.prototype.toString`
with a host object, the result will often be one of those values.


results either "[object Function]" or "[object Object]". That behavior
is allowed in ES3, but why not in ES5? ES5 seems to defy what most (if
not all) implementations do there.

Some host objects including `alert` are implemented as a native
ECMAScript objects (`alert instanceof Function`). In that case, the
[[Class]] property should be "Function".

However according to ES5 specs, any host object must not be withing
the set of values that are not allowable and so the assertion could be
made that if any object has a [[Class]] that is one of those values,
then the object is not a host object. An `isHostObject` method could
be written using a RegExp:

var _toString = Object.prototype.toString,
    nativeClasses =

function isHostMethod(m) {
  return !nativeClasses.test(.call(m));

However, we know that won't hold true in many cases more than just `alert`.

Is the specification wrong here or what am I missing?


More information about the es-discuss mailing list