"Ian Renfrew" <ian_renfrew@sy mpatico.ca> writes:
[color=blue]
> Does Javascript supply a function that destroys an object?[/color]
No. There is no such operator or function in ECMAScript, nor in any of
the implementations that I have heard of.
Destroying an object is generally a bad idea, since it would leave
variables with references to that object dangling ... or require that
they are all found and changed.
[color=blue]
> If so, is there a dependancy on Javascript version?[/color]
No :)
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
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 <ian_renfrew@sy mpatico.ca>
wrote:
[color=blue]
> Does Javascript supply a function that destroys an object? If so, is
> there a
> dependancy on Javascript version?
>
> Thanks in advance, Ian Renfrew
>
>[/color]
"Danny" <dann90038@blue bottle.com> wrote in message
news:1117497986 .a2ccacc788f9f4 aa1824b861a63e2 9d0@teranews...[color=blue]
>
> 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
> <ian_renfrew@sy mpatico.ca> wrote:
>[color=green]
>> Does Javascript supply a function that destroys an object? If so, is
>> there a
>> dependancy on Javascript version?
>>
>> Thanks in advance, Ian Renfrew[/color][/color]
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 objectToBeDestr oyed = new Object();
var anotherReferenc e = objectToBeDestr oyed;
objectToBeDestr oyed = null
-objectToBeDestr oyed- is not being "copied to /dev/null" because it is
still reachable.
Even adding:
anotherReferenc e = 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 <gwagner@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Comment