I have this
array = ["column1", "column2", "column3"]
and this other
array = ["infor1", "infor2", infor3"]
I would like to do this:
{
column1: infor1,
column2: infor2,
column3: infor3
}
I have this
array = ["column1", "column2", "column3"]
and this other
array = ["infor1", "infor2", infor3"]
I would like to do this:
{
column1: infor1,
column2: infor2,
column3: infor3
}
You can try to do something like this,
const props = ["column1", "column2", "column3"];
const values = ["infor1", "infor2", "infor3"];
props.reduce((acc, itm, i) => (acc[itm] = values[i], acc) , {});
You can read more about .reduce here.
var array1 = ["column1", "column2", "column3"]
var array2 = ["infor1", "infor2", "infor3"]
var obj = {};
array1.forEach(function(y, z) {
obj[y] = array2[z];
});
console.log(obj)