Skip to content

Instantly share code, notes, and snippets.

@Aleksey-Danchin
Created October 10, 2016 08:06
Show Gist options
  • Save Aleksey-Danchin/7a9b1b9ed8bf4fd605595e71a7d88138 to your computer and use it in GitHub Desktop.
Save Aleksey-Danchin/7a9b1b9ed8bf4fd605595e71a7d88138 to your computer and use it in GitHub Desktop.
Фильтрация массива на уникальные элементов
let array = [1, 'b', 3, 'f', 'f', 'd', 'a', 9, 'b', 8, 'd', 4, 9, 'a', 5, 10, 3, 'c', 8, 7, 7, 6, 1, 'g', 'a', 'g', 4, 'e', 9, 8, 6, 5, 5, 2, 'c', 'd', 'e', 1, 6, 4, 2, 'b', 3, 10, 'e', 'f', 2, 'c', 10, 'g', 7];
array = array.filter((e, i, l) => i == l.lastIndexOf(e));
console.log(array); // => [ 'a', 9, 8, 5, 'd', 1, 6, 4, 'b', 3, 'e', 'f', 2, 'c', 10, 'g', 7 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment