Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
Created March 3, 2012 05:56
Show Gist options
  • Save cormacrelf/1964607 to your computer and use it in GitHub Desktop.
Save cormacrelf/1964607 to your computer and use it in GitHub Desktop.
function Animal() {
this.eyes = 2;
this.legs = 4;
this.name = "Animal";
this.mutate = function () {
this.eyes += 1;
this.legs += 1;
this.name = this.name + "...";
};
}
var snake = new Animal();
snake.eyes = 2;
snake.legs = 0;
snake.name = "Snake";
console.log("Here's a snake.");
console.log(snake);
console.log("Let's mutate him!");
snake.mutate();
console.log(snake);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment