Skip to content

Instantly share code, notes, and snippets.

@philogb
Last active December 12, 2015 12:38
Show Gist options
  • Save philogb/4773616 to your computer and use it in GitHub Desktop.
Save philogb/4773616 to your computer and use it in GitHub Desktop.
function inherit(from, to) {
function F() {}
F.prototype = from.prototype;
to.prototype = new F();
}
var Animal = function() {
};
Animal.prototype.eat = function() {
console.log('eating');
};
var Person = function() {
};
inherit(Animal, Person);
Person.prototype.sayHi = function() {
console.log('person saying hi');
};
var p = new Person();
p.eat();
p.sayHi();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment