我有1个包含对象的数组:
one = [
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'}
]
我想从所有帐户中删除key
,该怎么做?
答案 0 :(得分:3)
一种方法是遍历并删除属性
one.forEach(o => delete o.key);
答案 1 :(得分:2)
您可以执行以下操作
const one = [
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'},
{name: 'Name', key: '4868466'},
]
const result = one.map((item) => {
delete item.key
return item
})
console.log("result:", result)