javascript - How to map a Array and create a Object from it? -


below code....

var temp = {}; [{group_id : "1111"}, {group_id: "2222"}].map(function(ele, index) {     var group_id = ele.group_id;     temp.group_id = {value: 0} }); 

after run code, temp object is

 {group_id : {value : 0} 

but want

{ {"1111" : {value : 0}}, {"2222" : {value : 0}} } 

how can that?

instead of using temp.group_id use temp[group_id].


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -