Garrett Smith (2014-08-12T19:36:07.000Z)
On 8/12/14, Claude Pache <claude.pache at gmail.com> wrote:
>
> Le 12 août 2014 à 18:44, Garrett Smith <dhtmlkitchen at gmail.com> a écrit :
>
>> What's the explanation and reason for this strange characteristic of
>> the OBJECT element in Firefox?
>>
>> Firefox 31:
>> typeof document.createElement("object")
>> "function"
>> Function.prototype.toString.call(document.createElement("object"));
>> TypeError: Function.prototype.toString called on incompatible object
>>
>> If the typeof OBJECT results "function" then it either:
>> a) implements [[Call]] or
>> b) is exotic
>>
>> Since calling `Function.prototype.toString` with OBJECT as the this
>> value results in a TypeError, it appears that the OBJECT does not
>> implement [[Call]] and thus the only explanation is that the OBJECT is
>> exotic. Did I get that right? Or is there another explanation?
>>
>> What's the explanation and reason for this strange characteristic of
>> the OBJECT element in Firefox?
>
> According to comments 10-18 in
> https://bugzilla.mozilla.org/show_bug.cgi?id=268945 , object and embed
> elements do implement [[Call]] for some obscure reason. Hence `typeof`
> yielding "function".
>
> Maybe I'm splitting hairs, but the spec doesn't say explicitly that all
> objects implementing [[Call]] must support `Function.prototype.toString`,
> although I'm not sure that that omission was intentional. Anyway, if you
> want to test if an object implements [[Call]], the best method is simply to
> try to call it:
>
> 	document.createElement("object")()
>
Calling the OBJECT here does not result in a TypeError. If it were not
callable, then TypeError would have to be the result.

Thus, the OBJECT implements [[Call]]. Furthermore, the ReferenceError
that is thrown as a result of calling Function.prototype.toString on
that OBJECT is not explained by the OBJECT not implementing call.

To test if a function implements [[Call]], use the typeof operator.
-- 
Garrett
@xkit
ChordCycles.com
garretts.github.io
domenic at domenicdenicola.com (2014-08-22T21:22:29.764Z)
Calling the OBJECT here does not result in a TypeError. If it were not
callable, then TypeError would have to be the result.

Thus, the OBJECT implements [[Call]]. Furthermore, the ReferenceError
that is thrown as a result of calling Function.prototype.toString on
that OBJECT is not explained by the OBJECT not implementing call.

To test if a function implements [[Call]], use the typeof operator.