Skip to content

Instantly share code, notes, and snippets.

@jhihn
Created November 30, 2015 17:29
Show Gist options
  • Save jhihn/bcb7d152ba4b335c78c2 to your computer and use it in GitHub Desktop.
Save jhihn/bcb7d152ba4b335c78c2 to your computer and use it in GitHub Desktop.
merge any number of objects
function mergeObjects(){
var out = {};
var attrname;
for (var i =0; i< arguments.length; i++)
for (attrname in arguments[i]) { out[attrname] = arguments[i][attrname]; }
return out;
}
console.log(mergeObjects({a:1}, {b:2}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment