Re: [WebIDL] Interface object prototype and function object

Hi Philippe,

On 10/03/2012 05:43 PM, Philippe Le Hegaret wrote:
> In
>   http://dev.w3.org/2006/webapi/WebIDL/
>
> section 4.4.1 says: "The interface object for a given non-callback
> interface is a function object."
>
> section 4 says: "If an object is defined to be a function object, then
> it has characteristics as follows: Its [[Prototype]] internal property
> is the Function prototype object.[...]"
>
> Does this mean that:
>   typeof Document.prototype should return "function" ?
>
> If not, I'm wondering what I'm missing...

What you're missing is that obj.prototype doesn't return obj's 
[[Prototype]] internal property. You can get the [[Prototype]] internal 
property through Object.getPrototypeOf(obj) or obj.__proto__. In Gecko, 
at least,

w(typeof XMLHttpRequest)
w(typeof Object.getPrototypeOf(XMLHttpRequest))
w(typeof XMLHttpRequest.__proto__)

all print "function". (Using XMLHttpRequest because that's one of the 
few objects that use WebIDL-compliant bindings in Gecko.)

HTH
Ms2ger

Received on Wednesday, 3 October 2012 15:54:51 UTC