473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Javascript Destroy Object

Does Javascript supply a function that destroys an object? If so, is there a
dependancy on Javascript version?

Thanks in advance, Ian Renfrew
Jul 23 '05 #1
3 77546
"Ian Renfrew" <ia*********@sympatico.ca> writes:
Does Javascript supply a function that destroys an object?
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.
If so, is there a dependancy on Javascript version?


No :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

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


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3
"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
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Minkyu Kim | last post by:
Hi. Please check this simple test code. --------------------- class TestA: def __init__(self): print "init TestA" def __del__(self): print "del TestA" def SetEvent(self, event):
15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
7
by: Erik-Jan Bakker | last post by:
Hello, I am stuck with a weird javascript problem.... ;-( Maybe it's somehting very simple, but I am really stuck in it, right now. What's the matter.... When place my website at a different...
2
by: Miles Davenport | last post by:
My Javascript is rather rusty :( ... and I need to do change some form values, in the folowing way: (1). I have the following a href (wrapped in PHP), which calls processForm. ==== <input...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
16
by: Roman Ziak | last post by:
Hello, there were times when I used to be looking for a way to access JavaScript Global object similar to those found in VBScript or PHP ($GLOBALS). At present this has only academic value for...
1
by: Jim Ox | last post by:
I have created a custom validator control that implements the BaseValidator. However I would like to add an attribute to the JavaScript validation object that is rendered at the bottom of the...
4
by: semkin55 | last post by:
Here is a small program, that traces construction and distruction of class A objects. If I use make_pair to insert in a map everything is OK. If I insert using , than objects with index 11, 7 and...
1
by: tgorton | last post by:
I am having a problem running a javascript function as part of an html-el:form onsubmit. The problem seems to exists in IE6 but not in Firefox. html: <html-el:form action="${target}"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.