I've read some guides on scope in JS, but I don't quite get what's going on here.
This does work:
var b = 6;
function a(){
alert(b);
}
a(); //alerts 6
However, this makes Firebug say "x is not defined"
var funcB = function(){
alert(x);
}
function funcA(anonymous){
var x = 10;
anonymous();
}
funcA(funcB);
So why doesn't the free x variable in funcB get binded to the x declared to be 10 in the first line of funcA?
Thanks