> From: traunic
>
> Is there value in using the delete operator?
Yes, of course. Delete is good to use - when it's appropriate.
> function(foo){
> bar = foo + 3;
> if(bar < 10){...}
> delete bar;
> }
But not there! You should be using a local variable instead:
function(foo){
var bar = foo + 3;
if(bar < 10){...}
}
Use delete when you want to delete a property of an object, not as a
substitute for using local variables.
You don't need to use delete on a property of an object that will be
reclaimed by garbage collection anyway. But if you are keeping a reference
to an object and no longer need one of its properties, it certainly doesn't
hurt to delete the property. And of course if you *need* the property to go
away, by all means delete it.
-Mike