Skip to content

Instantly share code, notes, and snippets.

@benwells
Created March 13, 2014 15:59
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 benwells/9531184 to your computer and use it in GitHub Desktop.
Save benwells/9531184 to your computer and use it in GitHub Desktop.
filtering an array in javascript
var test = ["this is an element", "this is an element", "so is this"];
var unique = test.filter(function(elem, pos, self) {
return self.indexOf(elem) == pos;
});
console.dir(unique);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment