Equality Reform(ul)ation

Brendan Eich brendan at mozilla.com
Wed Jan 15 13:05:37 PST 2014



Kevin Smith wrote:
>
>
>         js> 0L == "0"
>         typein:2:0 TypeError: no operator function found for ==
>
>
>
> And what does this do?
>
>     0L == { valueOf() { return 0 } }

js> 0L == { valueOf: function() { return 0 } }
typein:2:0 TypeError: no operator function found for ==

> Is the Object-type operand converted to a primitive before the 
> overload is matched?

No, the multimethod dispatch algorithm runs. Even with ToObject (I see I 
left that out), there is no predefined @@ADD or @@ADD_R on 
Object.prototype, so the error above is inevitable.

/be


More information about the es-discuss mailing list