I have two arrays:
array1 = [\"Bob\", \"John\", \"Dave\"];
array2 = [1, 2, 3];
Is there combine the two into a javascript array filled with obj
You could use an object and iterate the keys and the values.
var array1 = ["Bob", "John", "Dave"],
array2 = [1, 2, 3],
object = { meta: array1, value: array2 },
result = Object.keys(object).reduce(function (r, k) {
object[k].forEach(function (a, i) {
r[i] = r[i] || {};
r[i][k] = a;
});
return r;
}, []);
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }