Similar to without, but returns the values from array that are not present in the otherarrays.

返回数组中的差集

_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
=> [1, 3, 4]

源码:

1   _.difference = function(array) {
2     var rest = _.flatten(slice.call(arguments, 1), true);
3     return _.filter(array, function(value){ return !_.include(rest, value); });
4   };

 

 

 

posted on 2012-04-15 23:12  himanhimao  阅读(870)  评论(0编辑  收藏  举报