const arr = [
{
id: 1,
name: 'index',
params: [],
},
{
id: 2,
name: 'glossaryDetail',
params: ['id'],
},
{
id: 3,
name: 'wordQuestionDetail',
params: ['id'],
},
{
id: 4,
name: 'questionDetail',
params: ['id'],
},
]
const a = arr.map(item => {
delete item.params;
return item;
})
console.log(a);
// 好像有很多时候会报错, 但是这个demo能跑, 不知道为什么
const b = arr.map(item => ({ id, name } = item))
console.log(b);
// 这种肯定没问题, 就是感觉代码有点重复了
const c = arr.map(item => {
const {id, name} = item;
return {id, name};
)
console.log(c);