I'm struggling to understand why the output of this command is not 10.
var x = 10;
console.log(this.x);
On the other hand, when x is global the output is indeed 10.
x = 10;
console.log(this.x);
how come in the first example it does'nt print '10'? x is a variable of "window" object, so 'this' should be window. what am i missing here?