const intersection = new Set(Array.from(set1).filter(x => set2.has(x))); const difference = new Set(Array.from(set1).filter(x => !set2.has(x)));