javaScript数组对象取出某一列

1、数组

1.1、需求

[ {id:3,name:'张三'}, {id:4,name:'李四'}, {id:5,name:'王五'}]

取出name列,并成新数组

['张三', '李四', '王五']

1.2、map

let arr = [ {id:3,name:'张三'},  {id:4,name:'李四'}, {id:5,name:'王五'}]
let arr2 = arr.map(v => {return v.name})

console.dir(arr2)
/*
    Array(3)
    0: "张三"
    1: "李四"
    2: "王五"
    length: 3
*/
posted @ 2022-06-10 15:23  pine007  阅读(1400)  评论(0编辑  收藏  举报