Created
January 22, 2016 08:10
-
-
Save aMarCruz/f5b1f511db4c1b5e4d95 to your computer and use it in GitHub Desktop.
Returns a new object with all the properties of the objects passed as parameters.
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
/** | |
* Returns a new object with all the properties of the objects passed as parameters. | |
* The parameters can be zero or more instances of Object or derivates. | |
* | |
* @returns {object} - Any number of objects | |
*/ | |
module.exports = function xmerge () { | |
var target = {} | |
for (var i = 0; i < arguments.length; i++) { | |
var source = arguments[i] | |
if (source) { | |
for (var k in source) { | |
if (source.hasOwnProperty(k)) { | |
target[k] = source[k] | |
} | |
} | |
} | |
} | |
return target | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment