You've written some version of this:



const intersection = new Set([...setA].filter(x => setB.has(x)));
const difference = new Set([...setA].filter(x => !setB.has(x)));
const union = new Set([...setA, ...setB]);






It works. It's also four lines of manual iteration for operations any set-theory textbook covers in a sentence....