Answers for "remove from array all elements exists in another array javascript"

1

remove item from array if exists in another array

myArray = myArray.filter( function( el ) {
  return !toRemove.includes( el );
} );
Posted by: Guest on September-30-2021
1

remove item from array if exists in another array

myArray = myArray.filter( ( el ) => !toRemove.includes( el ) );
Posted by: Guest on September-30-2021
1

remove the items in array which are present in another javascript

var myArray = [
  {name: 'deepak', place: 'bangalore'}, 
  {name: 'chirag', place: 'bangalore'}, 
  {name: 'alok', place: 'berhampur'}, 
  {name: 'chandan', place: 'mumbai'}
];
var toRemove = [
  {name: 'deepak', place: 'bangalore'},
  {name: 'alok', place: 'berhampur'}
];



myArray = myArray.filter(ar => !toRemove.find(rm => (rm.name === ar.name && ar.place === rm.place) ))
Posted by: Guest on June-15-2020

Code answers related to "remove from array all elements exists in another array javascript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language