ECMAScript 6 sets: union, intersection, difference [itertools — Functions creating iterators for efficient looping](https://docs.python.org/3/library/itertools.html] 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))); //..