Operator overloading for non-value objects

Brendan Eich brendan at mozilla.com
Tue Jan 14 22:22:08 PST 2014

That code deserves what it gets, good and hard. Including exceptions.


    On Jan 14, 2014, at 8:01 PM, Domenic Denicola  wrote:

    I was thinking of

    function thirdPartyLib(val) {
      return val ="0";

    thirdPartyLib(myLong); // exception
    thirdPartyLib(Number(myLong)); // works

        On Jan 14, 2014, at 22:50, "Brendan Eich"  wrote:

        Domenic Denicola wrote:

            Heh, yes, damned if you do, etc. etc. I was trying to think up a practical example where this would cause problems (e.g. in CSS libraries strings and numbers often mix), but all my cases involved an `=-using third party library, in which case you'd just pass it `Number(myLong)` instead of `myLong` directly and move on with your life.

        Wait, number works:

        js>  0L =0
        js>  0L + 1

        Are you thinking of string?


More information about the es-discuss mailing list