I am trying to edit an array of objects that I have based on another array.
For example, this is my array of objects:
var objs = [{
attending: 0, user: '123'
}, {
attending: 0, user: '456'
}, {
attending: 0, user: '789'
}];
And this is my array:
var arr = ['945', '456']
Since 456 exists within arr, I would like to remove that object from obj. Hence being the final result of:
var objs = [{
attending: 0, user: '123'
}, {
attending: 0, user: '789'
}];
I have tried both omit and pullByAll yet had no luck:
var newObj = _.omit(obj, arr);
var newObj = _.pullAllBy(obj, arr, 'user');
What would be the best approach to this while using Lodash? I understand that creating a Javascript function for this would be quite simple, although my app requires this to be done quite often, so would be good to have a simple Lodash function that is accessible.