Skip to content

Instantly share code, notes, and snippets.

@jgatjens
Created October 30, 2013 21:04
Show Gist options
  • Save jgatjens/7240250 to your computer and use it in GitHub Desktop.
Save jgatjens/7240250 to your computer and use it in GitHub Desktop.
Prototypal Inheritance
var BaseModel = function(type){
this.type = !type ? "BaseModel" : type ;
};
BaseModel.prototype.sayHello = function() {
return "Hello " + this.type;
};
var User = function() {
BaseModel.call(this);
};
User.prototype = Object.create(BaseModel.prototype);
var model = new User();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment