Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Forked from jido/gist:1126681
Created August 5, 2011 00:53
Show Gist options
  • Save robotlolita/1126695 to your computer and use it in GitHub Desktop.
Save robotlolita/1126695 to your computer and use it in GitHub Desktop.
How JS scoping messes with capture
var a = {};
a.foo = function() {
return "foo";
}
a.bar = function() {
return "bar";
}
var b = {other: a};
for (var f in a) {
b[f] = function(local_f) {
return a[local_f].call(a);
}(f)
}
b.foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment