ecmascript-operator-overloading-proposal
ecmascript-operator-overloading-proposal copied to clipboard
A proposal for operator overloading in ECMAScript
Currently the proposal states that the methods that provide the operator behavior should be static. I understand that this is the convention in other languages that implement operator overloading such...
👋 I was ready to write this proposal myself, but here it is! Could you use a hand?
For example: ``` const oldAdd = Number[Symbol.operator('+')]; Number[Symbol.operator('+')] = (a, b) => { if (typeof a != "number" or typeof b != "number") { console.log("warning: types coercion has occurred in...
``` class Thinger {} let thingerA = new Thinger() console.log(thingerA + 1) // "[object Obejct1]" ```