Ember.js equivalent?

Does Ember have a .difference function as an underline ? I have an ArrayController with a set of objects in each of them. I want to subtract all the objects in ArrayController2 from ArrayController1 :

 ArrayController1: 1 2 3 4 ArrayController2: 2 4 

Then make the difference:

 ArrayController1.difference(ArrayController2) => 1 3 
+4
source share
1 answer

I don't think there is one method that will do this, but you could write an assistant that essentially did the following:

 array1.reject((function(item) { return array2.contains(item); }), array2); 

Just iterate over array1 and reject everything that returns true for array2.contains ().

+6
source

All Articles