Skip to content

Instantly share code, notes, and snippets.

@fmtarif
Created January 13, 2014 12:15
Show Gist options
  • Save fmtarif/8399309 to your computer and use it in GitHub Desktop.
Save fmtarif/8399309 to your computer and use it in GitHub Desktop.
js filter() to get unique array values
var cats = ['tech','politics','tech','politics','spirituality'];
cats.filter(function(v,i){return cats.indexOf(v) == i}) // will return ["tech", "politics", "spirituality"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment