Computes the list of values that are the intersection of all the arrays. Each value in the result is present in each of the arrays.
返回数组的交集
1 _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); 2 => [1, 2]
源码:
1 _.intersection = _.intersect = function(array) { 2 var rest = slice.call(arguments, 1); 3 return _.filter(_.uniq(array), function(item) { 4 return _.every(rest, function(other) { 5 return _.indexOf(other, item) >= 0; 6 }); 7 }); 8 }