Let the storm money come!

jquery 数组求差集,并集

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) );

posted @ 2014-08-11 10:35  精密~顽石  阅读(6276)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。