in reply to Re: "When closures capture their context" and "scope gotchas in Javascript"
in thread "When closures capture their context" and "scope gotchas in Javascript"

Thanks moritz. Actually, I solved my JS problem by just declaring two different variables, instead of reusing the same variable:
function sayHello(name) { var sayAlert; var text = 'Hello ' + name; sayAlert = function() { alert(text); } var new_text='How confused am I?'; sayAlert(); } sayHello('Bob');

Not a terribly meaningful example because I don't actually USE new_text, but...

Perl++ for DWIM!

  • Comment on Re^2: "When closures capture their context" and "scope gotchas in Javascript"
  • Download Code