Skip to content

Instantly share code, notes, and snippets.

@FreekPaans
Created August 12, 2015 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreekPaans/2183cea1e7a5edd7bc9a to your computer and use it in GitHub Desktop.
Save FreekPaans/2183cea1e7a5edd7bc9a to your computer and use it in GitHub Desktop.
function Vector(x, y) {
this.x = x;
this.y = y;
this.Add = function(addend) {
if(!(addend instanceof Vector)) {
throw Error("addend not a Vector")
}
return new Vector(this.x + addend.x, this.y+addend.y)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment