Skip to content

Instantly share code, notes, and snippets.

@mauriciosoares
Created August 7, 2014 13:28
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 mauriciosoares/9a81a547862c0d455f3a to your computer and use it in GitHub Desktop.
Save mauriciosoares/9a81a547862c0d455f3a to your computer and use it in GitHub Desktop.
function User(attrs) {
for(var name in attrs) {
this[name] = attrs[name];
}
}
User.build = function(attrs) {
if(arguments.length === 2) {
attrs = {
name: arguments[0],
email: arguments[1]
}
}
return new User(attrs);
}
var user1 = User.build({
name: 'Mauricio',
email: 'm.soares'
});
var user2 = User.build('Mauricio', 'email2');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment