Skip to content

Instantly share code, notes, and snippets.

@moaoa
Created March 16, 2020 15:57
Show Gist options
  • Save moaoa/a7bcc803af7b16e68d97b76fb3ae719d to your computer and use it in GitHub Desktop.
Save moaoa/a7bcc803af7b16e68d97b76fb3ae719d to your computer and use it in GitHub Desktop.
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