Skip to content

Instantly share code, notes, and snippets.

@mbrowne
Last active August 29, 2015 14:06
Show Gist options
  • Save mbrowne/cb437f4573fd9b912833 to your computer and use it in GitHub Desktop.
Save mbrowne/cb437f4573fd9b912833 to your computer and use it in GitHub Desktop.
Pure prototypal inheritance in Javascript
var Animal = {
init: function(name) {
this.name = name || null;
}
}
var Cat = Object.create(Animal);
Cat.meow = function() {
console.log('meow');
}
var garfield = Object.create(Cat);
garfield.init('Garfield');
garfield.meow();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment