js set operations union intersection
// Union (a ∪ b)
let a = new Set([1,2,3]);
let b = new Set([4,3,2]);
let union = new Set([...a, ...b]);
// {1,2,3,4}
// Intersection (a ∩ b)
let a = new Set([1,2,3]);
let b = new Set([4,3,2]);
let intersection = new Set(
[...a].filter(x => b.has(x)));
// {2,3}
// Difference (a \ b)
let a = new Set([1,2,3]);
let b = new Set([4,3,2]);
let difference = new Set(
[...a].filter(x => !b.has(x)));
// {1}