Created
February 1, 2019 11:27
-
-
Save alexpilugin/782848132808d583c877c4421069abe1 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 arr = [ | |
{key:"11", value:"1100"}, | |
{key:"22", value:"2200"} | |
]; | |
var obj = arr.reduce(function(obj,item) { | |
obj[item.key] = item.value; | |
return obj; | |
},{}); | |
console.log(JSON.stringify(obj)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment