Created
March 12, 2015 08:03
-
-
Save wmakeev/9648157e9b8243d26e6d to your computer and use it in GitHub Desktop.
Call constructor without 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 SomeClass = function (options) { | |
if ( ! (this instanceof SomeClass)) { | |
return new SomeClass(options); | |
} | |
// code | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment