Skip to content

Instantly share code, notes, and snippets.

@joepie91

joepie91/.js

Created Mar 3, 2016
Embed
What would you like to do?
Object factory (without prototype) in JavaScript
function createUser(name, height, properties) {
return Object.assign({
name: name,
height: height,
noise: "hello world!",
makeNoise: function() {
console.log(this.noise);
}
}, properties);
}
var user = createUser("joepie91", "1.94m", {
noise: "hallo!"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.