Does Ember have a .difference function like underscore does? I have an ArrayController
with a set of objects in each one. I want to subtract all the objects in ArrayController2
from ArrayController1
:
ArrayController1:
1
2
3
4
ArrayController2:
2
4
Then do the difference:
ArrayController1.difference(ArrayController2) => 1
3
I don't think there is an single method that will do that, but you could write a helper that essentially did the following:
array1.reject((function(item) {
return array2.contains(item);
}), array2);
Just looping through array1 and rejecting anything that returns true for array2.contains().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With