Created
November 22, 2018 13:05
-
-
Save adefirmanf/72439ad445c813c6d0f1f822eef55d83 to your computer and use it in GitHub Desktop.
Set Collection
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
let A = new Set([1,2,6,4]) | |
let B = new Set([1,6,7,8]) | |
//Union | |
let union = [...A, ...B] | |
console.log("Union : ", union) | |
//Sliced | |
let sliced = [...A].filter(a => B.has(a)) | |
console.log("Sliced : ", sliced) | |
//Unique | |
let unique = new Set([...A, ...B]) | |
console.log("Unique : ", [...unique]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment