Created
March 16, 2020 15:57
-
-
Save moaoa/a7bcc803af7b16e68d97b76fb3ae719d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
et arrayOne=['1','2','1','2'] | |
console.log(arrayOne) | |
// ['1','2','1','2'] | |
let setOne= new Set(arrayOne) | |
for(elem of setOne){ | |
console.log(elem) | |
} | |
//'1' | |
//'2' | |
// Another way of doing | |
let setTwo= [...new Set(arrayOne)] | |
console.log(setTwo) | |
// ["1" ,"2"] | |
/* | |
Sets methods: | |
add | |
size | |
has | |
forEach | |
delete | |
clear | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment