Skip to content

Instantly share code, notes, and snippets.

@adefirmanf
Created November 22, 2018 13:05
Show Gist options
  • Save adefirmanf/72439ad445c813c6d0f1f822eef55d83 to your computer and use it in GitHub Desktop.
Save adefirmanf/72439ad445c813c6d0f1f822eef55d83 to your computer and use it in GitHub Desktop.
Set Collection
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