對比兩個數(shù)組不相同數(shù)據(jù)并提取
var arr1 = [0,1,2,3,4,5]
var arr2 = [0,4,6,1,3,9]
function getArrDifference(arr1, arr2) {
return arr1.concat(arr2).filter(function(v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v)
})
}
console.log(getArrDifference(arr1,arr2))
//輸出:(4) [2, 5, 6, 9]