Skip to content

Instantly share code, notes, and snippets.

@TJkrusinski
Created May 14, 2014 19:06
Show Gist options
  • Save TJkrusinski/993e33f594cb4bc7cb07 to your computer and use it in GitHub Desktop.
Save TJkrusinski/993e33f594cb4bc7cb07 to your computer and use it in GitHub Desktop.
/**
* Self constructing constructor?
*/
function Dog (props) {
if (!(this instanceof Dog)) return new Dog(props);
this.props = props || {};
};
Dog.prototype.bark = function () {
console.log.apply(console, arguments);
};
var fido = Dog({name: 'fido'});
fido.bark('I am an annoying dog');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment