Skip to content

Instantly share code, notes, and snippets.

@rickosborne
Created April 24, 2011 05:59
Show Gist options
  • Save rickosborne/939364 to your computer and use it in GitHub Desktop.
Save rickosborne/939364 to your computer and use it in GitHub Desktop.
JavaScript var hoisting
(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