Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Last active December 4, 2019 11:47
Show Gist options
  • Select an option

  • Save Farmatique/952f07a1bb53e7000258f80092a7b37f to your computer and use it in GitHub Desktop.

Select an option

Save Farmatique/952f07a1bb53e7000258f80092a7b37f to your computer and use it in GitHub Desktop.
Filtering array leaving only unique values
uniqueValuesArray = inputArray.filter(function(item, pos) {
return inputArray.indexOf(item) == pos;
})
//slightly different
uniqueValuesArray = inputArray.filter(function(item, pos, self) {
return self.indexOf(item) == pos;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment