Skip to content

Instantly share code, notes, and snippets.

@ekaraman89
Created March 16, 2020 08:42
Show Gist options
  • Save ekaraman89/58cb0dc5f1b207e9c3d1f960aa1cabb8 to your computer and use it in GitHub Desktop.
Save ekaraman89/58cb0dc5f1b207e9c3d1f960aa1cabb8 to your computer and use it in GitHub Desktop.
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
// usage example:
var a = ['a', 1, 'a', 2, '1'];
var unique = a.filter( onlyUnique ); // returns ['a', 1, 2, '1']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment