I'm just wondering if there is such a thing in JavaScript as a "local scope object". If you call a function, it has a context ( this ), which is the object it was called on ( function f() {return this;}; obj.f = f; obj.f(); //returns obj; ) , and the area that is created each time the function is called. The scope is used to define local variables, as in the following example:
var globalScopeVar = 1; (function() { var localScopeVar = 2; })();
In both areas, this refers to the global context (usually, window ), since the function was not called on any object. However, I am interested in the "scope object", i.e. An object in which variables are defined within the scope. For a global scope, this is usually a window , as is the global context:
window.globalScopeVar;
However, what is a "scope object" in the local scope of a function call? Does it exist or is it available? Is there a way to access an object where localScopeVar defined?
(function() { var localScopeVar = 2; localScope.localScopeVar;
What is localScope in this example?
Helge source share