Say I have two arrays of objects....
var oldProducts = [{id: "prod1", time: 10 clicks: 1342}, {id: "prod2", time: 3, clicks: 231289}, {id: "prod3", price: "$10", time: 0, clicks: 84238}];
var newProducts = [{id: "prod1", time 10, clicks: 0}, {id: "prod3", time: 3, clicks: 0}];
I want to find if a product in oldProducts is not in newProducts, based on the id and remove it.
I don't want to compare the entire object, as the products coming in can be different than the ones existing with some properties....but they shouldn't be removed.
My first thoughts are to use _.map on both and _.filter to find the tags in oldProducts to remove....and then remove those products from newProducts.
I feel though...it could be simpler than that though. Two maps, one filter, then I guess iterating over the newProducts again is a lot of iterations over n.
I can't use ES6.....unfortunately.