Skip to content

Instantly share code, notes, and snippets.

@susanahernandezd
Created March 11, 2020 10:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save susanahernandezd/250081a42d2ac0b9c2ffd386bcb68631 to your computer and use it in GitHub Desktop.
const array = ['one', 'one', 'two', 'three'];
//1. "Set"
[...Set(array)]
//2. "Filter"
array.filter((item, index) => array.indexOf(item) === index)
//3. "Reduce"
array.reduce((acc, item) => {
return acc.includes(item) ? acc : [...acc, item]
},[]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment