一,删除数组元素
let arr = [
{name:'拂晓',id:21111},
{name:'王小二',id:1111},
{name:'大小二',id:3222}
]
arr.splice(arr.findIndex(item => item.id === 3222), 1)
arr.filter(obj=>obj.id!==3222)
二,删除对象元素
let arr = {
name: '拂晓',
id: 1111,
age: 24
};
要领1:
const personUnkonwAge = (({name, id}) => ({name,id}))(arr)
console.log(personUnkonwAge)
console.log(arr)
要领二:
let {name, ...personUnknowName} = arr
console.log(personUnknowName)