接地气,兼容性好,支持IE8) function diff(arr1,arr2){ var a = []; var b = []; for(var i=0;i<arr2.length;i++){ a[arr2[i]]=true; } for(var i=0;i<arr1.length;i++){ if(!a[arr1[i]]){ b.push(arr1[i]); } } console.log(b) }
接地气,兼容性好,支持IE8) function diff(arr1,arr2){ var a = []; var b = []; for(var i=0;i<arr2.length;i++){ a[arr2[i]]=true; } for(var i=0;i<arr1.length;i++){ if(!a[arr1[i]]){ b.push(arr1[i]); } } console.log(b) }