Skip to content

Instantly share code, notes, and snippets.

@joepie91
Created March 3, 2016 16:11
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 joepie91/657f2b4b054d90aa0c87 to your computer and use it in GitHub Desktop.
Save joepie91/657f2b4b054d90aa0c87 to your computer and use it in GitHub Desktop.
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