Created
February 20, 2014 12:44
-
-
Save akagr/9112682 to your computer and use it in GitHub Desktop.
Borrowed from john resig's tutorial. A very nice example to test one's grasp on closures.
This file contains 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
var a = 5; | |
function runMe(a){ | |
assert( a == ___, "Check the value of a." ); | |
function innerRun(){ | |
assert( b == ___, "Check the value of b." ); | |
assert( c == ___, "Check the value of c." ); | |
} | |
var b = 7; | |
innerRun(); | |
var c = 8; | |
} | |
runMe(6); | |
for ( var d = 0; d < 3; d++ ) { | |
setTimeout(function(){ | |
assert( d == ___, "Check the value of d." ); | |
}, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment