Thank you for the clarification. It means that you need to perform N * M comparisons, where N and M are lengths of the two arrays. Do it in two nested loops.
This is simple is your array keys are consecutive integers and you know the sizes. In Javascript, any array is an associative container with any keys. If this is the concern, you can use
Object.keys
and iterate by keys. Please see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys[
^].
For better alternative, analyze how you end up having two different arrays with duplicate objects and think at preventing this situation in first place, when you add objects to the array.
—SA