例子:
let list=[
{
id:1,
name:'zhangsan'
},
{
id:2,
name:'zhangsan'
},
{
id:3,
name:'zhangsan'
},
{
id:4,
name:'zhangsan'
}
]
function getNames(list) {
let arr = [];
list.forEach( (item, index) => {
arr.push(item.name);
})
return arr;
},
网友评论