Skip to content

Instantly share code, notes, and snippets.

@dogenpunk
Created August 7, 2012 12:17
Show Gist options
  • Save dogenpunk/3284852 to your computer and use it in GitHub Desktop.
Save dogenpunk/3284852 to your computer and use it in GitHub Desktop.
JS 'new' Object instantiation protection
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