Skip to content

Instantly share code, notes, and snippets.

@CristalT
Created January 18, 2019 16:52
Show Gist options
  • Save CristalT/7793205d2c367d4fcd214514827cf9c8 to your computer and use it in GitHub Desktop.
Save CristalT/7793205d2c367d4fcd214514827cf9c8 to your computer and use it in GitHub Desktop.
// Two ways to remove array duplicates
const array = [1, 2, 3, 4, 4, 4, 5]
// Way 1
let uniq = array.filter((el, index) => array.indexOf(el) === index)
console.log(uniq)
// Way 2
uniq = [...new Set(array)]
console.log(uniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment