Please do this!!
Opened this issue · 1 comments
matthew-dean commented
JavaScript allows so much meta-programming, such as being able to define toString()
, or valueOf
or Symbol.toPrimitive to define how custom objects interact with primitives, but it becomes extremely limited when it comes to user objects interacting with other user objects in a developer-friendly way.
I would love proper operator overloading.
That said... I don't see the need for with operators
. Like Symbol.toPrimitive
, it seems like objects should be able to define how they interact with other objects / primitives, with fallbacks to native behavior for a behavior that is not specifically defined.
tbontb-iaq commented
We can override Symbol.Operator.+
or Symbol.Operator.Plus
to change object plus beheavior.