Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // Метод 1
  2. const array = ['Alex','👧','Mark','👧','Melisa','👧'];
  3. const uniqArray = array.reduce((uniq, item) => {
  4. return uniq.includes(item) ? uniq : [...uniq, item];
  5. }, [])
  6.  
  7. console.log(uniqArray);
  8.  
  9. // Метод 2
  10.  
  11. const array = ['Alex','👧','Mark','👧','Melisa','👧'];
  12. const uhiqArray = [...new Set(array)]]; // или const uhiqArray = Array.from(new Set(array));
  13.  
  14. // Метод 3
  15.  
  16. const array = ['Alex','👧','Mark','👧','Melisa','👧'];
  17. const uniqArray = array.filter((item,index) => {
  18. return index === array.indexOf(item);
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement