"Danny" <da*******@bluebottle.com> wrote in message
news:1117497986.a2ccacc788f9f4aa1824b861a63e29d0@t eranews...
The way I've removed an object to it nulls out, just like using cp obj
/dev/null, send to null, in js, assign to null, obj=null; .
Danny
On Tue, 24 May 2005 11:45:20 -0700, Ian Renfrew
<ia*********@sympatico.ca> wrote:
Does Javascript supply a function that destroys an object? If so, is
there a
dependancy on Javascript version?
Thanks in advance, Ian Renfrew
Setting an object reference null does not "null the object out" or "copy
the object to /dev/null"... it sets that object reference to null. If
that reference were the last reference to the object, the object is
eligible for garbage collection. If that reference were not the last
reference to the object, then the object is still reachable and will not
be garbage collected.
var objectToBeDestroyed = new Object();
var anotherReference = objectToBeDestroyed;
objectToBeDestroyed = null
-objectToBeDestroyed- is not being "copied to /dev/null" because it is
still reachable.
Even adding:
anotherReference = null;
will not "null out the object", it simply makes the object unreachable
and eligible for garbage collection. There is no guarantee that it will
be garbage collected. In fact, in a short-lived script, the garbage
collector may not run at all during the execution of the script although
it's almost certain to run when the page is torn down (you close the
browser or navigate away from the page).
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq