Created
August 7, 2012 12:17
-
-
Save dogenpunk/3284852 to your computer and use it in GitHub Desktop.
JS 'new' Object instantiation protection
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
function Something () { | |
if (! (this instanceof arguments.callee)) { | |
return arguments.callee(arguments); | |
} | |
} | |
// Guarantees that the object will be instantiated via new Object method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment