Skip to content

Instantly share code, notes, and snippets.

@susanahernandezd
Created March 10, 2020 13:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save susanahernandezd/b8748278a845a47333803573b84e0cda to your computer and use it in GitHub Desktop.
const array = [
{ id: 1, name: 'a1' },
{ id: 2, name: 'a2'},
{ id: 3, name: 'a3'},
{ id: 4, name: 'a4'},
{ id: 5, name: 'a5'},
];
const anotherArray = [
{ id: 1, name: 'a1'},
{ id: 2, name: 'a2'}
];
const result = array.filter(elem => {
return !anotherArray.find(({ id }) => id === elem.id )
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment