When two collections overlap, their intersection keeps only members present in both. With JavaScript Sets, this finds shared items such as people who belong to two groups. section 9.3.3
Listing 9.22. Intersection of sets
const ninjas = new Set(["Kuma", "Hattori", "Yagyu"]);
const samurai = new Set(["Hattori", "Oda", "Tomoe"]);
const ninjaSamurais = new Set(
[...ninjas].filter(ninja => samurai.has(ninja)) #A
);
assert(ninjaSamurais.size === 1, "There's only one ninja samurai");
assert(ninjaSamurais.has("Hattori"), "Hattori is his name");
Spread one Set into an array, filter for values present in the other Set, then wrap the matches in a new Set. Here, Hattori is the only shared member. section 9.3.3




