Skip to content

Instantly share code, notes, and snippets.

@xrd
Created June 30, 2010 00:07
Show Gist options
  • Save xrd/458024 to your computer and use it in GitHub Desktop.
Save xrd/458024 to your computer and use it in GitHub Desktop.
// 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