Created
December 4, 2014 09:20
-
-
Save akiva/f4bb157c8a00b4bb084b to your computer and use it in GitHub Desktop.
This file contains 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
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