Created
March 13, 2014 15:59
-
-
Save benwells/9531184 to your computer and use it in GitHub Desktop.
filtering an array in javascript
This file contains hidden or 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
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