On Aug 24, 11:09 pm, traunic <[EMAIL PROTECTED]> wrote: > wade = function(boo){ > bar = boo + 3; > if(bar < 10){...} > delete bar; > }; ... > if I am understanding correctly you are saying that 'wade' and 'bar' > would both be global variables in this instance.
Yes. If you don't qualify a local variable with 'var', JS treats it as a global. > Also that 'far' > would be automatically cleaned up by the engine after any call to > 'mark' returns. Is this correct? Yes and no - 'far' is MADE AVAILABLE FOR CLEANUP at that point, but is not necessarily cleaned up that instant. The garbage collector runs at arbitrary times which are completely non-deterministic (which simply means "100% unpredictable"). There is nothing in the language standard specifying exactly when the garbage collector must do its work. > And to take this to an extreme: ... > wade: function(boo){ > bar = boo + 3; ... > Is 'bar' still global? If you don't qualify it with 'var' then JS treats it as global. That said, it will not be introduced into the global namespace until it is actually referenced (when wade() is called, or you use bar in another global context, whichever comes first). :)