Skip to content

Instantly share code, notes, and snippets.

@latentflip
Created June 23, 2011 22:26
Show Gist options
  • Save latentflip/1043783 to your computer and use it in GitHub Desktop.
Save latentflip/1043783 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
var a_function = function() {
var a_number = 2;
document.write('Within a_function, a_number = '+a_number+'<br>');
return function(a) {
document.write('Within the callback, a_number = '+a_number+'<br>');
document.write('Within the callback, I was passed = '+a+'<br>');
document.write('Within the callback, a * a_number = '+a*a_number+'<br>');
}
};
var callback = a_function();
document.write('Outwith a_function, a_number = '+window.a_number+'<br>');
callback(10);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment