📜  js 将 2 个数组组合到对象键值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:21.908000             🧑  作者: Mango

代码示例1
var columns = ["Date", "Number", "Size", "Location", "Age"];
var rows = ["2001", "5", "Big", "Sydney", "25"];
var result =  rows.reduce(function(result, field, index) {
  result[columns[index]] = field;
  return result;
}, {})

console.log(result);