Created
January 27, 2012 13:13
-
-
Save cccaldas/1688710 to your computer and use it in GitHub Desktop.
js oop
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
| //oop | |
| Function.prototype.extends = function(parentClassOrObject){ | |
| if(parentClassOrObject.constructor == Function) | |
| { | |
| //normal inheritance | |
| this.prototype = new parentClassOrObject; | |
| this.prototype.constructor = this; | |
| this.prototype.super = parentClassOrObject.prototype; | |
| } | |
| else | |
| { | |
| //pure virtual inheritance | |
| this.prototype = parentClassOrObject; | |
| this.prototype.constructor = this; | |
| this.prototype.super = parentClassOrObject; | |
| } | |
| return this; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment