Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove a specific element in array of objects javascript es6

const fruits = [
  {id:1, name: 'Banana'},
  {id:2, name: 'Apple'},
  {id:3, name: 'Kiwi'}
]

// Remove Apple with id '2'
const newFruits = fruits.filter(fruit => fruit.id !== 'Apple')
console.log(newFruits)
//  [
//    {id:1, name: 'Banana'},
//    {id:3, name: 'Kiwi'}
//  ]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #specific #element #array #objects #javascript
ADD COMMENT
Topic
Name
9+3 =