您的位置:首页 > Web前端

underscore.js _.difference[Array]

2012-04-15 23:12 344 查看
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]


源码:

_.difference = function(array) {
var rest = _.flatten(slice.call(arguments, 1), true);
return _.filter(array, function(value){ return !_.include(rest, value); });
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: