Calling toString on function proxy throws TypeError exception
Boris Zbarsky
bzbarsky at mit.edu
Tue Oct 27 13:18:23 UTC 2015
On 10/27/15 9:14 AM, Boris Zbarsky wrote:
> On 10/27/15 4:35 AM, Claude Pache wrote:
>> it is that, for any callable object, it will return a string and not
>> throw, because it was so since the dawn of JS.
>
> It's totally false for random "host objects" with a [[Call]] in ES5, per
> spec and in at least some implementations. As you can tell in Firefox
> for example:
>
> Function.prototype.toString.call(document.createElement("object"))
>
> (though it does not throw for document.all in Firefox, for interesting
> implementation reasons).
Though note that I would be just fine with defining
Function.prototype.toString to return something akin to what it does for
"host functions" for any "host object" with a [[Call]]...
-Boris
More information about the es-discuss
mailing list