I want to compare two huge arrays, I'm reading those two arrays in batches (getting 10 objects per time from each array). After complete reading those two arrays, I want to have the following data (The intersection between the two huge arrays - Objects exist in the first array only -Objects exist in the second array only). What is the best practice to do that?
Example in small scale:
let arr1 = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7];
let arr2 = [ obj7, obj2, obj5, obj1, obj9, obj8];
Then I will read the two arrays in batches (two elements per time):
First loop
->obj2 is mutual
->obj1 exist in arr1 only
->obj7 exist in arr2 only
The issue here, it is not the final result until I complete looping on the whole arrays to get the correct result which is:
The mutual objects are obj1,obj2,obj5,obj7
Objects in arr1 only are obj3,obj4,obj6
Objects in arr2 only are obj8,obj9
Note: I've to read the arrays in batches because they are too big.