var set1 = new Set([1,2,3]);
var set2 = new Set([2,3,4]);
并集
let union = new Set([...set1, ...set2]);
交集
let intersect = new Set([...set1].filter( x => set2.has(x)));
差集
let difference = new Set([...set1].filter(x => !set2.has(x)));
出处:http://blog.csdn.net/haijing1995/article/details/72842810
时间: 2024-10-17 02:38:00