Created
October 15, 2014 18:02
-
-
Save argshook/7ce8007507fef995968d to your computer and use it in GitHub Desktop.
If you want to make sure your object is always instantiated with `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 myObject(options) { | |
if(!(this instanceOf myObject)) | |
return new myObject(options); | |
} | |
var object = myObject({}); // acts as if was instantiated with new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment