Skip to content

Instantly share code, notes, and snippets.

@akiva
Created December 4, 2014 09:20
Show Gist options
  • Save akiva/f4bb157c8a00b4bb084b to your computer and use it in GitHub Desktop.
Save akiva/f4bb157c8a00b4bb084b to your computer and use it in GitHub Desktop.
var human = { race: 'human' };
var person = { name: 'Jim', age: 26 };
function mixin(target, source, props) {
props = props || Object.keys(source);
props.forEach(function(prop) {
target[prop] = source[prop];
});
return target;
}
// => { name: 'Jim', age: 26, race: 'human' }
console.log(mixin(person, human));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment