Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Merge objects in javascript
/**
* Merge objects
*
* @param {...object} obj
*
* @return {object}
*/
function merge() {
var i, obj, key,
result = {};
for (i = arguments.length - 1; i >= 0; i--) {
obj = arguments[i];
for (key in obj) {
if (obj.hasOwnProperty(key)) {
result[key] = obj[key];
}
}
}
return result;
}
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.