In that last example, we added a reference to the object, inside the variable obj. By setting obj to null, we eliminate the last reference to the object we stored in our set. Therefore, because this is a WeakSet, the object is garbage-collected in order to free memory.
Hope it's clear :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In that last example, we added a reference to the object, inside the variable
obj
. By settingobj
to null, we eliminate the last reference to the object we stored in our set. Therefore, because this is a WeakSet, the object is garbage-collected in order to free memory.Hope it's clear :)