-
-
Save bloodyowl/7edc9c973d2236ed17e1 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
var user = { | |
create: function create() { | |
return this.constructor.apply(Object.create(this), arguments) | |
}, | |
constructor: function User(firstname, lastname) { | |
this.firstname = firstname | |
this.lastname = lastname | |
return this | |
}, | |
getName: function getName() { | |
return this.firstname + " " + this.lastname | |
}, | |
} | |
user.create("John", "Doe").getName() // "John Doe" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment