A set union combines the elements of two sets into a new set. Shared elements appear only once, so Hattori can serve on both rosters without counting as two warriors. section 9.3.2
Listing 9.21. Using sets to perform a union of collections
const ninjas = ["Kuma", "Hattori", "Yagyu"]; #A
const samurai = ["Hattori", "Oda", "Tomoe"]; #A
const warriors = new Set([...ninjas, ...samurai]); #B
assert(warriors.has("Kuma"), "Kuma is here"); #C
assert(warriors.has("Hattori"), "And Hattori"); #C
assert(warriors.has("Yagyu"), "And Yagyu"); #C
assert(warriors.has("Oda"), "And Oda"); #C
assert(warriors.has("Tomoe"), "Tomoe, last but not least"); #C
assert(warriors.size === 5, "There are 5 warriors in total"); #D
The example spreads two arrays into one, then passes the combined values to Set, which keeps Hattori only once. section 9.3.2



