Created
June 30, 2010 00:07
-
-
Save xrd/458024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// So, if I have this code: | |
function doSomething() { | |
var a = 1; | |
client.addListener( 'response', handleResponse ); | |
} | |
function handleResponse(data) { | |
// this should crash, right? | |
sys.puts( "Total: " + a ); | |
} | |
// Whereas this should work, no? | |
function doSomething() { | |
var a = 1; | |
client.addListener( 'response', function(data) { handleResponse( data, a ) } ); | |
} | |
function handleResponse( data, a ) { | |
// this should work, right? | |
sys.puts( "Total: " + a ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment