I have an allItems
array of objects
allItems = [
{ id: 1, name: 'item1' },
{ id: 2, name: 'item2' },
{ id: 3, name: 'item3' }
]
I want it to filter out and not contain the objects contained in another array from my component.
fewItems = [
{ id: 2, name: 'item2' }
]
so, filteredItems
should be :
filteredItems = [
{ id: 1, name: 'item1' },
{ id: 3, name: 'item3' }
]
And when another object from allItems
is added to fewItems
, it needs to disappear from the filteredItems
one.
I would like to do this in pure vanilla JS, with no specific library.
Thanks ahead !