Created
May 14, 2014 19:06
-
-
Save TJkrusinski/993e33f594cb4bc7cb07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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