You do not destroy the object itself if you set the property that contains the reference to it ( instanceOfTestFun
) to null
. You can only indirectly destroy the object by deleting the last reference to it (that is, at that moment the value held by testObj.pointerToFun
), so it will be garbage collected.
Under no circumstances can you remove the testObj
property without reference to it.
Do not confuse properties ( instanceOfTestFun
, testObj
, testObj.pointerToFun
) with the values that they can hold (property references, like after testObj.pointerToFun = instanceOfTestFun
or simple values like 9
or null
).
source share