📌  相关文章
📜  从数组中删除元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:50.201000             🧑  作者: Mango

代码示例6
const apps = [
  {id:1, name:'test1'}, 
  {id:2, name:'test2'},
  {id:3, name:'test3'}
]
//remove item with id=2
const itemToBeRemoved = {id:2, name:'test2'}
apps.splice(apps.findIndex(a => a.id === itemToBeRemoved.id) , 1)
//print result
console.log(apps)