두 배열의 간단한 비교 : JSON.stringify -> 문자열로 변경해 준 뒤 비교하는 방법.
const arr1 = ['1', '2', '3', '4', '5'];
const arr2 = ['1', '2'];
console.log(JSON.stringify(arr1) === JSON.stringify(arr2));
교집합과 차집합의 경우, Array 의 filter 와 includes prototype Method 로 비교 가능.
교집합 :
let intersection = arr1.filter(x => arr2.includes(x));
차집합:
let difference = arr1.filter(x => !arr2.includes(x));