Sets Flashcards
1
Q
Create set
A
let set = new Set()
2
Q
Add value to set
A
set.add(value)
3
Q
Check if value exists
A
set.has(value)
4
Q
Delete value from set
A
set.delete(value)
5
Q
Remove duplicates from array
A
let uniqueArray = […new Set(array)]
6
Q
Find length of set
A
set.size
7
Q
Clear set
A
set.clear()
8
Q
convert set to array
A
let myArray = Array.from(mySet)
9
Q
Convert set to array
A
let myArray = […mySet]
10
Q
Loop through set
A
for (let value of mySet) {
console.log(value)
}