var x = 16;
console.log(this["x"]); // 16
I'm ok with this, but:
(function () {
var y = 16;
console.log(this["y"]); // undefined
}());
Why we cant access variables via this
?!
I know it's possibe when we assign values, for example:
(function () {
x = 16; // will assigned as `this["x"] = 16`
console.log(x); // 16;
}());
What's var
problem with non-global scopes?!