Operators overriding

KOLANICH kolan_n at mail.ru
Fri Dec 18 20:24:59 UTC 2015


Hello. What do you think about overriding operators using proxies?
For example
function A(r=""){
this.rep=r;
return new Proxy(this,{operators:{"+":function(a,b){return new A(a.rep+"+"+b.rep);}}});
}
let a=new A("a"), b=new A("b");
let c=a+b;
console.log(c.rep);//a+b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151218/a3178799/attachment.html>


More information about the es-discuss mailing list