Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: "When closures capture their context" and "scope gotchas in Javascript"

by clinton (Priest)
on Feb 08, 2008 at 16:36 UTC ( [id://667010]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://667010]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-16 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found