Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Remove #specific #object #Array #Javascript
ADD COMMENT
Topic
Name
7+6 =