let Arr = [
{id:1,name:'张飞'},
{id:2,name:'关羽'},
{id:3,name:'刘备'},
{id:4,name:'嘟嘟'},
]
Arr.forEach((element,index) => {
console.log(element,"element")
if (element.id == '4') {
console.log(index)
Arr.splice(index,1)
}
});
删除数组对象中指定的元素
最新推荐文章于 2023-11-28 15:34:08 发布