我有下一个数组:
let someArr = [
{param:{name: 'bla'}},
{param:{name: 'blu'}}
];
如何不使用'param'来获得数组?
[{name: 'bla'},{name: 'blu'}]
答案 0 :(得分:1)
let someArr = [
{param:{name: 'bla'}},
{param:{name: 'blu'}}
];
const result = someArr.map(el => el.param);
console.log(result);
答案 1 :(得分:0)
let newArray = someArr.map(item => {
return item.param;
});