Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created January 12, 2022 02:17
Show Gist options
  • Select an option

  • Save ancyrweb/82414626353167f646302b1173c344d0 to your computer and use it in GitHub Desktop.

Select an option

Save ancyrweb/82414626353167f646302b1173c344d0 to your computer and use it in GitHub Desktop.
const elements = [1, 2, 3, 1, 4, 5, 2, 6, 6];
const isUnique = (value, index, array) => array.indexOf(value) === index;
const nextElements = elements.filter(isUnique); // [1, 2, 3, 4, 5, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment