Quote WeakMap Section ,
If the object that is used as the key of the WeakMap key / value pair is accessible only through the chain of links that begins with this WeakMap, then this key / value pair is unavailable and is automatically deleted from WeakMap.
In your case, the only way to achieve o is to start with one of the keys in WeakMap , since there are no external links to it. Therefore, it will be deemed unavailable.
WeakMap implementations should detect and remove such key / value pairs and any associated resources.
So this will be the ultimate garbage collection.
source share