const setA = new Set([1, 2, 4, 5]) const setB = new Set([5,4, 3]) // 并集 res = new Set([...setA, ...setB]) // 交集 res = new Set([...setA].filter( item => setB.has(item))) // 差集 res = new Set([...setA].filter( item => !setB.has(item))) console.log(res)