Created
December 12, 2022 02:06
-
-
Save jslnriot/5cd1b90c2be473c522059ca5bb3b0c91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create some sets | |
let setA = new Set([1, 2, 3, 4]); | |
let setB = new Set([3, 4, 5, 6]); | |
let setC = new Set([5, 6, 7, 8]); | |
// create a new set with the union of setA, setB, and setC | |
let unionSet = new Set([...setA, ...setB, ...setC]); | |
console.log(unionSet); // Set {1, 2, 3, 4, 5, 6, 7, 8} | |
// create a new set with the intersection of setA, setB, and setC | |
let intersectionSet = new Set([...setA].filter(x => setB.has(x) && setC.has(x))); | |
console.log(intersectionSet); // Set {5, 6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment