map处理数组对象

2019-04-08  本文已影响0人  _hider

将数组对象的键值作为数组返回

var data = [
    {
        username: 'don'
    },
    {
        username: 'alice'
    }
]

let newArr = data.map((res, index) => {
    return res.username;
})
console.log(newArr) //['don','alice']
上一篇 下一篇

猜你喜欢

热点阅读