Variable-variables inside function scope?

No, there's no object you can use to access var variables within function contexts (even though they are properties of an object called the "variable object" of that execution context; the object has no exposed name and so cannot be accessed directly). The var thing in the global context is a bit of a special case, and you shouldn't rely on it (although the spec does define it). If you want to access those variables as properties of the global object ( window in the case of web browsers), explicitly assign them to window properties rather than using var for clarity: window.

X = 'my value or if you prefer: window"x" = 'my value (Those two statements have identical results, both create/set a property called "x" on the window object. ).

No, there's no object you can use to access var variables within function contexts (even though they are properties of an object called the "variable object" of that execution context; the object has no exposed name and so cannot be accessed directly). The var thing in the global context is a bit of a special case, and you shouldn't rely on it (although the spec does define it). If you want to access those variables as properties of the global object (window, in the case of web browsers), explicitly assign them to window properties rather than using var, for clarity: window.

X = 'my value'; or if you prefer: window"x" = 'my value'; (Those two statements have identical results, both create/set a property called "x" on the window object. ).

I pretty much knew this would be the answer. Just wanted to hear it from someone else :p – spudly Dec 4 '09 at 17:41 Though if you wanted to, you could create a locally scoped object and use it in that way eg: function someFunc(){ var localVars = {}; localVars. Variable1 = ' alert(localVars"variable1"); } Not entirely sure why you'd want to, but as with all things in javascript, I'm sure it would have some when other methods are too tedious or not flexible enough.

– Graza Dec 4 '09 at 18:45 +1 For talking about the Variable Object, the Execution Context creation concept is not really widespread known... A good more in-depth article: is. Gd/5cxyl – CMS Dec 4 '09 at 20:26.

However, when you're inside of a function and you use the 'var' keyword, the variables you create are locally scoped to the function they are declared in. Is there some object that can be used with the bracket syntax (like window) to get access to the locally scoped variables? I doubt it's possible, but thought I'd ask just for kicks.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions