Skip to content

Instantly share code, notes, and snippets.

@xthecapx
Created November 3, 2015 12:37
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 xthecapx/7fa5378364dcf57e3068 to your computer and use it in GitHub Desktop.
Save xthecapx/7fa5378364dcf57e3068 to your computer and use it in GitHub Desktop.
Create and using constructor
function Fencepost(x, y, postNum) { //Constructor
this.x = x;
this.y = y;
this.postNum = postNum;
this.connectionsTo = [];
this.sendRopeTo = function(connectedPost) {
this.connectionsTo.push(connectedPost);
};
}
// Using constructor
var post = new Fencepost(-3, 4, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment