Created
February 4, 2015 08:57
-
-
Save ipmsteven/ecf623802eda074534b5 to your computer and use it in GitHub Desktop.
js new
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
| var Class = function(){ | |
| var klass = function(){ | |
| this.init.apply(this, arguments); | |
| }; | |
| klass.prototype.init = function(){}; | |
| return klass; | |
| }; | |
| // Case 1 | |
| var Person = new Class; | |
| Person.prototype.init = function(){ | |
| // Called on Person instantiation | |
| }; | |
| // Usage: | |
| var person = new Person; | |
| // Case 2 | |
| var Person = Class(); | |
| Person.prototype.init = function(){ | |
| // Called on Person instantiation | |
| }; | |
| // Usage: | |
| var person = new Person; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment