js Array map映射对象多个属性

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);

const b = arr.map(item => ({ id, name } = item))
console.log(b);
[
  { id: 1, name: 'index' },
  { id: 2, name: 'glossaryDetail' },
  { id: 3, name: 'wordQuestionDetail' },
  { id: 4, name: 'questionDetail' }
]
[
  { id: 1, name: 'index' },
  { id: 2, name: 'glossaryDetail' },
  { id: 3, name: 'wordQuestionDetail' },
  { id: 4, name: 'questionDetail' }
]

你可能感兴趣的:(javascript,前端,vue.js)