daily pastebin goal
93%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top