underscore.js _.intersect[Array]
2012-04-15 23:09
381 查看
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.
返回数组的交集
源码:
返回数组的交集
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); => [1, 2]
源码:
_.intersection = _.intersect = function(array) { var rest = slice.call(arguments, 1); return _.filter(_.uniq(array), function(item) { return _.every(rest, function(other) { return _.indexOf(other, item) >= 0; }); }); }
相关文章推荐
- underscore.js _.flatten[Array]
- underscore.js _without [Array]
- underscore.js _.union[Array]
- underscore.js _.difference[Array]
- underscore.js _uniq[Array]
- underscore.js _.zip[Array]
- underscore.js _indexOf[Array]
- underscore.js _.lastIndexOf[Array]
- underscore.js _range[Array]
- underscore.js _.first[Array]
- underscore.js _.initial[Array]
- underscore.js _last[Array]
- underscore.js _reset[Array]
- underscore.js中 cb 函数与optimizeCb函数
- underscore.js,js工具库
- underscore.js中的类型检测
- underscore.js _.values[Object]
- underscore.js _.isObject[Object]
- underscorejs
- underscorejs-contains学习