Skip to content

Instantly share code, notes, and snippets.

@gustavom
Created October 5, 2016 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavom/d28d92fb948ad7b3a8fefa29cead43e1 to your computer and use it in GitHub Desktop.
Save gustavom/d28d92fb948ad7b3a8fefa29cead43e1 to your computer and use it in GitHub Desktop.
Filtragem de valores repetidos de um array, gerando um novo array
var arr = ['foo', 'bar', 'foo'];
var novaArr = arr.filter(function(este, i) {
return arr.indexOf(este) == i;
})
console.log(novaArr); //dá ['foo', 'bar']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment