Hacker News new | past | comments | ask | show | jobs | submit login

How? WeakMap (and WeakSet, more directly) can detect if an object has been collected only if you have a reference to pass to it. If you have reference to the object in a variable or data structure, it won't have been eligible for collection in the first place.



You can't use a WeakMap or a WeakSet, but you can use a WeakRef or a FinalizationRegistry.


I did not know about these things. Looks cool!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: