Skip to content

Instantly share code, notes, and snippets.

@koji
Last active July 6, 2020 13:57
Show Gist options
  • Save koji/0f6fcb4d14f2c539de9626ca5dde28bf to your computer and use it in GitHub Desktop.
Save koji/0f6fcb4d14f2c539de9626ca5dde28bf to your computer and use it in GitHub Desktop.
uniqueArray es6
const originalArray = [1, 2, 3, 4, 1, 2, 3, 4];

const uniqueArray = new Set(originalArray);
console.log(uniqueArray);
const originalArray = [1, 2, 3, 4, 1, 2, 3, 4]

const uniqueArray = originalArray.filter((item, index, array) => {
  return array.indexOf(item) === index
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment