Skip to content

Instantly share code, notes, and snippets.

@julsfelic
Created April 20, 2013 17:35
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 julsfelic/5426762 to your computer and use it in GitHub Desktop.
Save julsfelic/5426762 to your computer and use it in GitHub Desktop.
Scope safe constructor example
function Person(name, age, job) {
if (this instanceof Person) {
this.name = name;
this.age = age;
this.job = job;
} else {
return new Person(name, age, job)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment