I thought I understood scope however, while thinking of a particular code problem I had, I am confused by the following:
var a = {
aFunc: function() {
console.log(x);
}
};
var b = {
bFunc: function() {
var x = c.x;
console.log(x);
a.aFunc();
}
};
var c = {
x: 'x is in c'
};
b.bFunc();
Question: aFunc
is called inside bFunc
, why do I get 'x is not defined'
inside aFunc
? Isn't this a simple closure where a.aFunc
can access b.bFunc
scope?