Exotic OBJECT?

Boris Zbarsky bzbarsky at MIT.EDU
Wed Aug 13 14:04:42 PDT 2014


On 8/12/14, 12:44 PM, Garrett Smith wrote:
> If the typeof OBJECT results "function" then it either:
> a) implements [[Call]]

That's exactly what it does.  This allows making plug-in objects 
callable if the plug-in decides to do so.

> Since calling `Function.prototype.toString` with OBJECT as the this
> value results in a TypeError, it appears that the OBJECT does not
> implement [[Call]]

Nope.  It definitely implements [[Cal]]; I can point you to the part of 
the code where that's done if you care.

The issue you're seeing is that in SpiderMonkey 
Function.prototype.toString will throw if its 'this' value is not a 
Function object (as defined based on internal [[Class]] like checks, not 
based on [[Call]]; in particular note that Object.prototype.toString 
does _not_ return "Function" for an <object> in SpiderMonkey).  So it 
throws for various callables that aren't actually functions.

-Boris


More information about the es-discuss mailing list