How to combine 2 array to be 1 array with object and key. array1 = [a, b, c , d]
array2 = [z, y, x, w] I want to be an array like result = [[foo: a, bar: z], [foo: b, bar: y], [foo: c, bar: x], [foo: d, bar: w]]. I just can combine without object and key like this:
var array1 = [a, b, c , d];
var array2 = [z, y, x, w];
var result = [];
result = $.map(array1, function (el, idx) {
return [[el, array2[idx]]];
});
output: [[a, z],[b, y],[c, x],[d, w]];