const arrayDiff = (a, b) => a.concat(b).filter((item, index, arr) => arr.indexOf(item) === arr.lastIndexOf(item))
const a = [2, 3, 4, 1]
const b = [5, 4, 3, 2, 1]
console.log(
arrayDiff(a, b)
)
输出:[ 5 ]
const arrayDiff = (a, b) => a.concat(b).filter((item, index, arr) => arr.indexOf(item) === arr.lastIndexOf(item))
const a = [2, 3, 4, 1]
const b = [5, 4, 3, 2, 1]
console.log(
arrayDiff(a, b)
)
输出:[ 5 ]