Here is a code snippet i tried out.
[code=javascript]
var array = new Array(12,20,"De basis Jana");
alert(array.len gth);
delete array.length;
alert(array.len gth);
[/code]
Basically first i tried to delete the array then i did this to delete a property.
It's not working, before this what i tried ....
[code=javascript]
var o = new MyClass();
for(i in o) if(o.hasOwnProp erty(i)) alert(i);
delete o.prop1;
for(i in o) if(o.hasOwnProp erty(i)) alert(i);
[/code]
It's working, now my question is that how delete works in JavaScript?
Basically JavaScript engine uses a garbage collector then why delete comes in?
One more thing if i do ...
[code=javascript]
delete o.prop1;
o.prop1 = null;
[/code]
what do these two mean?
I gone a mess. :-)
[code=javascript]
var array = new Array(12,20,"De basis Jana");
alert(array.len gth);
delete array.length;
alert(array.len gth);
[/code]
Basically first i tried to delete the array then i did this to delete a property.
It's not working, before this what i tried ....
[code=javascript]
var o = new MyClass();
for(i in o) if(o.hasOwnProp erty(i)) alert(i);
delete o.prop1;
for(i in o) if(o.hasOwnProp erty(i)) alert(i);
[/code]
It's working, now my question is that how delete works in JavaScript?
Basically JavaScript engine uses a garbage collector then why delete comes in?
One more thing if i do ...
[code=javascript]
delete o.prop1;
o.prop1 = null;
[/code]
what do these two mean?
I gone a mess. :-)
Comment