I needed something similar, comparing two arrays containing identifiers but in random order. In my case: "does this array contain at least one identifier from the other list?" The code is quite simple, using the reduce-function.
function hasFullOverlap(listA, listB){
return listA.reduce((allIdsAreFound, _id) => {
// We return true until an ID has not been found in the other list
return listB.includes(_id) && allIdsAreFound;
}, true);
}
if(hasFullOverlap(listA, listB) && hasFullOverlap(listB, listA)){
// Both lists contain all the values
}