var x = 5,
o = {
x: 10,
doIt: function doIt(){
var x = 20;
setTimeout(function(){
alert(this.x);
}, 10);
}
};
o.doIt();
Why is this referring to window object rather than o
. I am inside the object o
context, so it should print me 10 right?