JS: WeakSet
what is WeakSet
WeakSet is similar to the the Set Object , with 3 exceptions:
- Item can only be Object Type, or unregistered Symbol type (meaning, symbols user created, not builtin symbols.).
- If a item in the set is not used elsewehere in your program, or no longer used, that item is deleted automatically.
- WeakSet cannot be iterated over, nor get its item count, nor clear all.
All methods for WeakSet.
adddeletehas
// demo, of all methods for WeakSet const ws = new WeakSet(); const xkey = { "hi": 3 }; // add ws.add(xkey); // has console.assert(ws.has(xkey) === true); // delete ws.delete(xkey); console.assert(ws.has(xkey) === false);