Created
June 20, 2009 00:10
-
-
Save inklesspen/132963 to your computer and use it in GitHub Desktop.
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 foo = function() { | |
var funcs = []; | |
for (var i=0; i < 5; i++) { | |
funcs[i] = function() {alert("The number is " + i);}; | |
} | |
return funcs | |
}; | |
var f = foo() | |
f[0](); // You will expect this to show a box with 0 | |
f[4](); // And this to show a box with 4. But they both show 5. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment