commit bca504ac76d26716a90bd4f58552c289fcb2243e Author: Sven Slootweg Date: Fri Aug 3 22:47:10 2012 +0200 Add core inheritance functionality diff --git a/core.js b/core.js new file mode 100644 index 0000000..dec2e78 --- /dev/null +++ b/core.js @@ -0,0 +1,19 @@ +Function.prototype.inheritsFrom = function(parentClassOrObject) +{ + if ( parentClassOrObject.constructor == Function ) + { + //Normal Inheritance + this.prototype = new parentClassOrObject; + this.prototype.constructor = this; + this.prototype.parent = parentClassOrObject.prototype; + } + else + { + //Pure Virtual Inheritance + this.prototype = parentClassOrObject; + this.prototype.constructor = this; + this.prototype.parent = parentClassOrObject; + } + + return this; +}