Can I define custom operator overloads in Javascript? [duplicate]
I agree that the equal function on the vector prototype is the best solution. Note that you can also build other infix-like operators via chaining. function Vector(x, y, z) { this.x = x; this.y = y; this.z = z; } Vector.prototype.add = function (v2) { var v = new Vector(this.x + v2.x, this.y + v2.y, … Read more