作者在 2018-03-15 12:47:28 发布以下内容
并集(union)
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)
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)
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}
参考:http://2ality.com/2015/01/es6-set-operations.html