473,395 Members | 1,720 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,395 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 77558
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.