Created
August 7, 2014 13:28
-
-
Save mauriciosoares/9a81a547862c0d455f3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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