I like the functional approach to achieve this task:
var arr = [{ key:"11", value:"1100" }, { key:"22", value:"2200" }];
var result = arr.reduce(function(obj,item){
obj[item.key] = item.value;
return obj;
}, {});
Note: Last {}
is the initial obj
value for reduce function, if you won't provide the initial value the first arr
element will be used (which is probably undesirable).