The type Point uses fake operator overloading and lets you do the following:
var Point = require("./point.js").Point; var p = new Point(); p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6); console.log(p.toString()); // Point(9, 12) Caveats:
- The overloaded operators only work when used together with an assignment, in the above manner.
"" + mypointwon't invoketoString(), butvalueOf(). Work-around:"" + mypoint._