Given the following array
[60, 1456]
How can I determine which items in this object do not have a corresponding id to the numbers in the array?
[
{id: 60, itemName: 'Main Location - Cleveland'},
{id: 1453, itemName: 'Second Location - Cleveland'},
{id: 1456, itemName: 'Third Location - New York'}
]
2
Answers
// Efficient approach
Use
filter()
combined withincludes()
to check if theid
does not (!
) exists in theids
array: