jquery 数组求差集,并集

时间:2014-08-11 11:42:42   收藏:0   阅读:1530

var alpha = [1, 2, 3, 4, 5, 6],
beta = [4, 5, 6, 7, 8, 9];

$.arrayIntersect = function(a, b)
{
return $.merge($.grep(a, function(i)
{
return $.inArray(i, b) == -1;
}) , $.grep(b, function(i)
{
return $.inArray(i, a) == -1;
})
);
};

window.console && console.log( $.arrayIntersect(alpha, beta) );

jquery 数组求差集,并集,布布扣,bubuko.com

原文:http://www.cnblogs.com/zlfucku/p/3904179.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!