in reply to "When closures capture their context" and "scope gotchas in Javascript"
// untested! function sayHello(name){ var sayAlert; var newScope = function() { var text = 'Hello' + name; sayAlert = function() { alert(text) } } newScope(); var text = 'How confused am I?'; sayAlert(); }
And that's why you want to program in perl, not in javascript (wherever possible).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "When closures capture their context" and "scope gotchas in Javascript"
by clinton (Priest) on Feb 08, 2008 at 16:36 UTC | |
|
Re^2: "When closures capture their context" and "scope gotchas in Javascript"
by Jenda (Abbot) on Feb 08, 2008 at 23:25 UTC |