PDA

View Full Version : How to remove object?


timur
02-18-2003, 03:48 PM
// I've created an object of my own class

function myClass(var1, var2, var3){
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
}

obj1 = new myClass('a', 'b', 'c');

// now i need to destroy this object

obj1 = null;

/* but whn i do that the typeof(obj1) is still 'Object'.
is it possible to do something that type of my object
will become 'undefined'? */

beetle
02-18-2003, 05:13 PM
What langauge are you writing in? Looks like PHP. Is this really a javascript question?

Anyhow, NULL is a null object, so what typeof reports is correct. Just try this

alert( typeof null );

So, don't check the type of the object but rather it's value.

Anyhow, this is all kind of moot (http://sharkysoft.com/tutorials/jsa/content/021.html) anyways.

timur
02-19-2003, 08:43 AM
Thats ok.

But i really need to change the type of my object to 'undefined'.
Is it possible?

beetle
02-19-2003, 01:49 PM
No, not that I know of.

Owl
02-19-2003, 10:43 PM
Hi Guys,

delete obj1

( •) (• )
>>V

beetle
02-19-2003, 11:01 PM
Originally posted by Owl
delete obj1 Duhh! :rolleyes:

That's the last time I link up an article without checking the date first! (Jan, 11 1997!!!)

How embarassing! :o

Yes, it's delete obj1;

// or just a property

delete obj1.var1;I (obviously) never had a use for this ;)

timur
02-20-2003, 11:38 AM
thanks guys

i thik that's all