Created
August 28, 2012 02:44
-
-
Save timhall/3494452 to your computer and use it in GitHub Desktop.
Example implementation of inheritance implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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