var foo = \'bar\';
console.log(window.foo); // bar
Seems like variables get assigned as properties to this
, but inside anonymous funct
To cite http://perfectionkills.com/understanding-delete/#execution_context:
Every execution context has a so-called
Variable Object
associated with it. Similarly to execution context, Variable object is an abstract entity, a mechanism to describe variable instantiation. Now, the interesing part is that variables and functions declared in a source text are actually added as properties of this Variable object.When control enters execution context for Global code, a
Global object
is used as aVariable object
. This is precisely why variables or functions declared globally become properties of aGlobal object
Yet, these Variable Object
s are not accessible. The only non-internal one is the global object, window
or this
(in global context).
The relevant section in the specification is #10: Executable Code and Execution Contexts.