Created
April 26, 2011 15:54
-
-
Save JamesRyanATX/942532 to your computer and use it in GitHub Desktop.
Classical Inheritance in JS
This file contains hidden or 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
TinyOOP = { }; | |
TinyOOP.Class = function(definition) { | |
var klass = function() { | |
if (typeof this.initialize !== 'undefined') this.initialize.apply(this, arguments); | |
} | |
for (key in TinyOOP.Class.Methods) { klass[key] = TinyOOP.Class.Methods[key]; } | |
for (key in definition) { klass.prototype[key] = definition[key]; } | |
return klass; | |
} | |
TinyOOP.Class.Methods = { | |
subclass: function(definition) { | |
var klass = TinyOOP.Class(this.prototype); | |
for (key in definition) { klass.prototype[key] = definition[key]; } | |
klass._super = this; | |
return klass; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment