Answers for "how to remove a particular obj in an array of objects javascript"

0

Remove specific object from the Array in Javascript

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)
Posted by: Guest on July-14-2021

Code answers related to "how to remove a particular obj in an array of objects javascript"

Browse Popular Code Answers by Language