var alpha = [1, 2, 3, 4], beta = [1,2,3]; var 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) );