Please provide an explanation why the output will be 4. I am trying to understand that the output is 4 but cannot find the reason why is it not 3.
var x=4,
obj={
x: 3,
bar:function(){
var x = 2;
setTimeout(function(){
var x=1;
console.log(this.x);
},1000);
}
}
obj.bar();