Last active
December 16, 2015 11:39
-
-
Save queckezz/5429046 to your computer and use it in GitHub Desktop.
instantiate a function without using the 'new' keyword
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 constructor( args ) { | |
if( !(this instanceof constructor) ) return new constructor( args ); | |
// ... constructor stuff | |
} | |
constructor.prototype.method() {}; | |
constructor.method(); | |
/* | |
* instead of: | |
* new constructor; | |
* constructor.method(); | |
* Just: | |
* constructor.method(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment