Closed Thread Icon

Preserved Topic: delete an Object (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18162" title="Pages that link to Preserved Topic: delete an Object (Page 1 of 1)" rel="nofollow" >Preserved Topic: delete an Object <span class="small">(Page 1 of 1)</span>\

 
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 03-13-2002 14:06

Sorry for my simple questions, but i'm still at the beginning of learning javascript.

How can i delete an object?

hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 03-13-2002 18:34

Not sure exactly what you're trying to accomplish. If you have object o, you can set its value to null:

code:
var o = new Object;
o = null;



Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-14-2002 01:40

If I understand correctly, you want to take an object or variable that you've declared, and make it as though you never declared it. This can be done with the delete operator:

var myvariable = 3;
delete myvariable;

This gives the variable the "undefined" value, as though it had never existed in the first place.

One should know that the delete operator in JavaScript has very little to do with the delete operator in other languages, such as C++.

Now, that said, I've personally never had a use for this. Why don't you tell us more about what you're trying to do, because I suspect there may be a better way to solve the problem you're trying to solve.

« BackwardsOnwards »

Show Forum Drop Down Menu