Created
April 24, 2011 05:59
-
-
Save rickosborne/939364 to your computer and use it in GitHub Desktop.
JavaScript var hoisting
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
(function(items) { | |
var taxFuncs = []; | |
for(var x in items) { | |
taxFuncs.push(function(){ | |
return x * 1.1; | |
}); | |
} | |
return taxFuncs; | |
})([5,10,20])[1](); // returns 22, not 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment