1. 使用 filter、concat 来计算
const a = [1, 2, 3, 4, 5];
const b = [2, 4, 6, 8, 10];
const jj = a.filter(v => b.includes(v));
const bj = a.filter(v => !b.includes(v)).concat(b);
const cj = a.filter(v => !b.includes(v));
const buj = a.filter(v => !b.includes(v)).concat(b.filter(v => !a.includes(v)));
2. 使用拓展运算符(...)、Set 的特性来计算
const a = [1, 2, 3, 4, 5];
const b = [2, 4, 6, 8, 10];
const sa = new Set(a);
const sb = new Set(b);
const intersection = a.filter(v => sb.has(v));
const union = [...a.filter(v => !sb.has(v)), ...b];
const minus = a.filter(v => !sb.has(v));
const complement = [...a.filter(v => !sb.has(v)), ...b.filter(v => !sa.has(v))];