Skip to content

Instantly share code, notes, and snippets.

@ondrek
Last active August 29, 2015 13:56
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 ondrek/9095617 to your computer and use it in GitHub Desktop.
Save ondrek/9095617 to your computer and use it in GitHub Desktop.
Javascript Inheritance
Core = function(){};
Core.prototype.logger = function(arg){
console.log(+Date(), arg);
};
var base = new Core();
base.logger("Samuel!"); // 3909024909 Samuel!
base.prototype.isSamuel = true;
base.prototype.logger = function(arg){
console.log("I'm awesome!");
this.base()
};
var base = new Core();
base.logger("Peter!"); // 3909024909 Peter!
base.prototype.isSamuel = true;
base.prototype.logger = function(arg){
console.log("I'm awesome!");
this.base()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment