Created
November 30, 2015 17:29
-
-
Save jhihn/bcb7d152ba4b335c78c2 to your computer and use it in GitHub Desktop.
merge any number of objects
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
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