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. Object.prototype.toString.call(alert); 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: // DO NOT USE var _toString = Object.prototype.toString, nativeClasses = /Array|Boolean|Date|Error|Function|JSON|Math|Number|Object|RegExp|String/; 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? Garrett _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss