Skip to content

Instantly share code, notes, and snippets.

@bloodyowl

bloodyowl/.js Secret

Created December 2, 2015 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodyowl/7edc9c973d2236ed17e1 to your computer and use it in GitHub Desktop.
Save bloodyowl/7edc9c973d2236ed17e1 to your computer and use it in GitHub Desktop.
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