我们有一个数组名称
let name = [
['Ободович', 'Иван'],['Булий' , 'Андрей'],['Булий', 'Андрей']
]
let res = name.forEach((elem) => {
let data = Object.create(null, {lastName: {value:''}, firstName: {value:''})
data.lastName = elem[0];
data.firstName = elem[1]
})
console.log(res)
期待
res = [
{lastName:'Ободович', firstName:'Иван'},
{lastName:'Булий', firstName:'Андрей'},
{lastName:'Булий', firstName:'Андрей'}
]
forEach()方法不返回任何内容。使用map()方法