I have 2 different arrays filled with objects which have properties
Let’s name them arrays A and B
I want array A to have all the items B has and removing all items A has that B does not have.
Essentially is B has an item A already has, it does nothing. If B has an item A does not have, it adds it. And if A has an item B does not have, it removes it.
And finallly after all that I get the final result of array A
Are you asking how to compare two objects or are you just confused about the algorithm that would help you identify which objects should be transferred from a to b?
If A has all the items in B, and none of the items that are not in B, then you can simply make A a copy of B, unless you want to preserve the original order of the items in A.