let ages = [13, 23, 32, 41, 53]
let names = ['zs', 'ls', 'ww', 'zl']
let arr = []
names.forEach((item, index) => {
let obj = {}
obj.name = item
obj.age = ages[index]
arr.push(obj)
})
console.log(arr);
【记录】将两个数组合并成一个对象数组--JS
于 2022-07-15 11:56:07 首次发布