📌  相关文章
📜  如何使用 JavaScript map() 方法访问嵌套对象? - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:03.138000             🧑  作者: Mango

代码示例1
//access value by using map
var personsInfo = {
    company: 'sp-coder',
    persons: [{
        id: 1,
        name: 'Adil'
    }, {
        id: 2,
        name: 'Arif'
    }]
};
const getNames = personsInfo.persons.map((data) => data.name);
console.log(getNames);
//Expected Output is [ 'Adil', 'Arif' ]