Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Метод 1
- const array = ['Alex','👧','Mark','👧','Melisa','👧'];
- const uniqArray = array.reduce((uniq, item) => {
- return uniq.includes(item) ? uniq : [...uniq, item];
- }, [])
- console.log(uniqArray);
- // Метод 2
- const array = ['Alex','👧','Mark','👧','Melisa','👧'];
- const uhiqArray = [...new Set(array)]]; // или const uhiqArray = Array.from(new Set(array));
- // Метод 3
- const array = ['Alex','👧','Mark','👧','Melisa','👧'];
- const uniqArray = array.filter((item,index) => {
- return index === array.indexOf(item);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement