WeakSet
Estimated reading time: 1 minuteset
- store reference
- grabage
let set = new Set(),
key = {null};
set.add(key);
console.log(set.size);
// 1
weakset
- don’t store reference
- no garbage
let set = new WeakSet(),
key = {null};
set.add(key);
console.log(set.size);
// undefined