I've got an array of objects that looks like this:
[{
itemType: 'bottle',
itemId: '111'
}, {
itemType: 'bottle',
itemId: '222'
}, {
itemType: 'bottle',
itemId: '333'
}]
My goal is to efficiently filter it (with a time complexity of O(n)) using a simple array like this:
[ '111', '333' ]
The end result should be an array of objects that looks like this:
[{
itemType: 'bottle',
itemId: '222'
}]
I initially considered using underscoreJS
, but there doesn't seem to be a built-in function for this specific task. Any other suggestions?