Skip to content

Instantly share code, notes, and snippets.

@aherve
Created August 30, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aherve/0b76f959005a23249bdd679136833475 to your computer and use it in GitHub Desktop.
Save aherve/0b76f959005a23249bdd679136833475 to your computer and use it in GitHub Desktop.
// subtract two sets
const s1 = [ 1, 2, 3, 4, 5 ]
const s2 = [ 2, 4 ]
const subtracted = s1.filter(x => s2.indexOf(x) < 0)
console.log(subtracted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment