单个数组中有两个不同的对象,如果值不同,我必须比较这些数组,然后我必须得到Array1值
Array1.push({
"Name": "Max",
"Occupation": "Agri",
"Location": "KGP"
});
Array2.push({
"Name": "Alex",
"Occupation": "S.E",
"Location": "Mut"
});
答案 0 :(得分:1)
您可以比较如下:
var array1 = [1, 2, 3, 4, 5, 6];
var array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var foo = [];
var i = 0;
jQuery.grep(array2, function(el) {
if (jQuery.inArray(el, array1) == -1) foo.push(el);
i++;
});
alert(" the difference is " + foo);