So I have a simple Javascript Object:
function Vector(x, y){
this.x = x;
this.y = y;
this.magnitude = function(){};
this.add = function(vector){};
this.minus = function(vector){};
this.normalise = function(){};
this.dot = function(vector){}
//...
}
I would like to perform the following operations:
var a = new Vector(1,1);
var b = new Vector(10,5);
var c = a + b
a += c;
// ... and so on
I know that it's possible to implement operators for Objects in other languages, would be great if I could do it in Javascript
Help would be very much appreciated. Thanks! :)