I have 2 arrays of objects.
Array1:
[{ id: 2, ref: 1010101 },
{ id: 2, ref: 1010107 }]
Array2:
[{ id: 2, ref: 10010001 },
{ id: 2, ref: 10010002 },
{ id: 2, ref: 10010003 },
{ id: 2, ref: 10010006 },
{ id: 2, ref: 10010007 },
{ id: 2, ref: 10010008 },
{ id: 2, ref: 10010009 },
{ id: 2, ref: 10020005 },
{ id: 2, ref: 1010101 }]
I need to do 2 tasks:
1. Find what elements of array1 are in array2 . After find Items, Im going to do something with that elements.
2. Remove elements found from array2. After I do something with my found items, I need to remove each item found.
I was trying to do it with lodash but without success.
I need something like this:
if(elementFound) {
//do something
doSomething(item);
//after it, remove from array2
removeItemFromArray2(item);
}
Thanks, I think there is an easy way to do it with lodash.
indexOfandsplice?