I need to find an object in array based on array of values and then remove them, this was easy when I only needed to find one item, I did it like this:
if (mdl.findObjectByKey(response, 'cat_id', 171) == true) {
console.log("item removed from dropdown");
var catId = response.map(item => item.cat_id).indexOf(171);
response.splice(catId, 1);
}
This would remove the item with a cat_id === 171 from the array of objects.
Now I need to remove more items so it would look something like this:
var itemsToRemove = [171, 182, 199, 234];
if (mdl.findObjectByKey(response, 'cat_id', itemsToRemove) == true) {
console.log("item removed from dropdown");
var catId = response.map(item => item.cat_id).indexOf(itemsToRemove);
response.splice(catId, 1);
}
Obviously, the above example does not work at all, I just wanted to explain what I needed.