Skip to content

Instantly share code, notes, and snippets.

@wtfil
Created October 11, 2013 14:40
Show Gist options
  • Save wtfil/6935834 to your computer and use it in GitHub Desktop.
Save wtfil/6935834 to your computer and use it in GitHub Desktop.
Unique elements of array
function uniq(array) {
return array.filter(function (val, index) {
return array.indexOf(val) === index;
});
}
@wtfil
Copy link
Author

wtfil commented Oct 11, 2013

uniq([1, 2, 4, 3, 2, 4]) // [1, 2, 4, 3]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment