Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

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'}
//  ]
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to generate a random number in javascript 
Javascript :: js scroll to bottom 
Javascript :: on scroll page jquery 
Javascript :: js change html lang 
Javascript :: jquery display block 
Javascript :: yarn create react app 
Javascript :: .gitignore nodejs 
Javascript :: how to get name array value in jquery 
Javascript :: javascript get scroll position 
Javascript :: shorthand for jquery document ready 
Javascript :: v-for i down 
Javascript :: z index style javascript 
Javascript :: kill all npm processes 
Javascript :: get header height jquery 
Javascript :: how to remove backslash from string in javascript 
Javascript :: javascript write in id 
Javascript :: get value onChange from mat-select angular 
Javascript :: remove all html tags from string javascript 
Javascript :: create element javascript with id 
Javascript :: Your global Angular CLI version (11.0.2) is greater than your local version 
Javascript :: react fetch post 
Javascript :: how to make directory in javascript 
Javascript :: jspdf text align center 
Javascript :: Emojis should be wrapped in <span, have role="img", and have an accessible description with aria-label or aria-labelledby 
Javascript :: beautifulsoup extract json from script elements 
Javascript :: internal/modules/cjs/loader.js:905 throw err; 
Javascript :: javascript length of object 
Javascript :: how to assign port in angular 
Javascript :: javascript change url hash 
Javascript :: javascript base64 encode string 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =