Skip to content

Instantly share code, notes, and snippets.

@cgatian
Created August 9, 2013 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgatian/6193693 to your computer and use it in GitHub Desktop.
Save cgatian/6193693 to your computer and use it in GitHub Desktop.
Guarantee the object is created using the constructor and not placing itself into the global namespace.
function Class()
{
if(!(this instanceof Class))
{
return new Class();
}
}
var _obj = Class();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment