Skip to content

Instantly share code, notes, and snippets.

@argshook
Created October 15, 2014 18:02
Show Gist options
  • Save argshook/7ce8007507fef995968d to your computer and use it in GitHub Desktop.
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
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