var foo = 'bar';
console.log(window.foo); // bar
Seems like variables get assigned as properties to this, but inside anonymous functions, this refers to the parent scope, but doesn’t assign variables to the parent scope.
function() {
var foo = 'bar';
}();
window.foo; // undefined
What object do variables get assigned to in non-global scopes?
To cite http://perfectionkills.com/understanding-delete/#execution_context:
Yet, these
Variable Objects are not accessible. The only non-internal one is the global object,windoworthis(in global context).The relevant section in the specification is #10: Executable Code and Execution Contexts.