Skip to content

Instantly share code, notes, and snippets.

@timhall
Created August 28, 2012 02:44
Show Gist options
  • Save timhall/3494452 to your computer and use it in GitHub Desktop.
Save timhall/3494452 to your computer and use it in GitHub Desktop.
Example implementation of inheritance implementation
var Parent = function (name) {
var _parent = this;
_parent.name = name;
}
Parent.prototype.sayHi = function () {
return 'Hi ' + this.name + '!';
}
Parent.sayHowdy = function () { return 'Howdy!' }
extendable(Parent);
var Child = function (firstName, lastName) {
var _child = Parent.inherit(this, firstName + ' ' + lastName);
_child.sayBye = function () {
return 'Bye ' + _child.name + ' :(';
};
return _child;
}
Parent.extend(Child, { protoProp: 4 }, { staticProp: 5 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment