Last active
August 29, 2015 14:07
-
-
Save cobbdb/395c34963c235c6ef77a to your computer and use it in GitHub Desktop.
Notes for dirt simple JS inheritance
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
function BaseClass(child) { | |
var key; | |
child = child || {}; | |
this.base = {}; | |
for (key in this) { | |
this.base[key] = this[key]; | |
} | |
for (key in child) { | |
this[key] = child[key]; | |
} | |
return this; | |
} | |
BaseClass.Abstract = function () { | |
throw Error('[BaseClass] Abstract method was called without definition.'); | |
}; | |
BaseClass.Stub = function () {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment