📌  相关文章
📜  从 Javascript 中的数组中删除特定对象 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:40.959000             🧑  作者: Mango

代码示例1
const apps = [
  {id:1, name:'Jon'}, 
  {id:2, name:'Dave'},
  {id:3, name:'Joe'}
]

//remove item with id=2
const itemToBeRemoved = {id:2, name:'Dave'}

apps.splice(apps.findIndex(a => a.id === itemToBeRemoved.id) , 1)

//print result
console.log(apps)