object and embed HTML elements are host objects.
ECMAScript3 11.4.3 did not determine what typeof should return for them. The return table for objects was
- Object (native and does not implement [[Call]]):
"object" - Object (native and implements [[Call]]):
"function" - Object (host): implementation dependent
However, the return of "function" corresponds to ECMAScript5 11.4.3 :
- Object (native and does not implement [[Call]]):
"object" - Object (native or host and implements [[Call]]):
"function" - Object (the host does not implement [[Call]]): The implementation, with the exception of, may not be
"undefined" , "boolean" , "number" or "string" .
object and embed HTML elements are objects with an internal [[Call]] property, so typeof should return "function" .
This is explained in Error 268945 :
Comment No. 15 , Boris Zbarsky:
[[Call]] is very intentional on the DOM side: these are called objects.
Comment # 16 , Tom Schuster:
This error is invalid, this object has an internal [[Call]] method and ES5 11.4.3 explicitly says "Object (native or _host_) and implements [[Call]])" => "function".
Since the object and embed HTML elements implement the internal [[Call]] property, they are callable objects. However, they are not functions:
4.3.24 function
a member of type Object, which is an instance of the standard built-in Function and which can be called as a routine
object HTML elements inherit from HTMLObjectElement.prototype and embed HTML elements from HTMLEmbedElement.prototype .
The prototype chain continues
HTMLObjectElement.prototypeHTMLElement.prototypeElement.prototypeNode.prototypeObject.prototype
Therefore, they are not Function instances because they are not inherited from Function.prototype .
source share