Skip to content

Instantly share code, notes, and snippets.

@shaggybb
Last active August 29, 2015 14:15
Show Gist options
  • Save shaggybb/4afbd2a01e7f16745064 to your computer and use it in GitHub Desktop.
Save shaggybb/4afbd2a01e7f16745064 to your computer and use it in GitHub Desktop.
Avoid duplicates in JavaScript
var a = [1,2,3,4,5,6,7,7,7,7,7,8];
a = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment