JS 여집합 찾아내기.
const A = [1, 2, 3, 4]; const B = [1, 3, 5, 7]; const diff = A.filter((x) => !B.includes(x)); console.log(diff); // [2, 4] ES6 의 'Set' 을 이용한 방법은 다음과 같다. let a = new Set([1, 2, 3, 4]); let b = new Set([1, 3, 5, 7]); let a_minus_b = new Set([...a].filter((x) => !b.has(x))); let b_minus_a = new Set([...b].filter((x) => !a.has(x))); let a_intersect_b = new Set([...a].filter((x) => b.has(x))); consol..