Possible Duplicate:
the delete operator in javascript
I have the following code. I don't understand why the second delete fails.
Also, I noticed that the foo function still exists even after I assigned something else to foo.
Is there a way to reference the function?
(suppose I'd want a bar2=foo()
to behave like the bar
assignment).
> function foo(){var bar=0; return function(){return bar++;}}
undefined
> bar = foo()
function () {return bar++;}
> bar()
0
> bar()
1
> delete bar
true
> foo = foo()
function () {return bar++;}
> foo()
0
> foo()
1
> delete foo
false
Thanks