I am having an array of objects and I want to create another object based on their keys. For example I am having an array as
var arr = [{1: 36011, 2: 18320, 3: 36011, 4: 10570},
{1: 19754, 2: 6722, 3: 19754, 4: 6699},
{1: 15711, 2: 10039, 3: 15711, 4: 4172}]
and I want my result array as
var result = {1:[36011,19754,15711], 2:[18320,6722,10039],..}
I was suggested to use lodash, I am new to this so I've tried using reduce
var i = 1, new_arr = {};
_.reduce(arr, function(key, val){
new_arr[i++] = temp1.key
return new_arr;
},{})
I am getting the values as undefined. What is the mistake, Can anyone help me with this?

iin your code is global, so it will count all the values. The reduce in your code cannot have key/val pair since you are applying it to an array.