Javascript functions are objects and they have scope chain associated with them.
If some closure exists with a function that has a different scope chain than the one that was in effect when they were defined.As an example invoking function is a returned function object from some other (parent) function that had a scope chain with a large number of private variables,
so invoking function will use the already existing inherited scope chain of parent function as well as bounded old variables.
Is there any way to check the variables associated with the scope chain without looking into the parent function?
Ideally one has to keep track of defined variables in the parent function, my question is without lookup of the parent function, can we see the variables associated with scope chain?
If yes (any method?) can we check the current value of variables associated with scope chain?
Also can someone give the structure of scope chain( at least i know its not like CPU stack like strucuture but something else?).
Scoped variables are available to the functions created in the same context (JavaScript is functionally scoped).
You have access to them but you can’t run a method to report them. If this is a common requirement, I suggest keeping internal variables handy in a “config” variable:
Nick Zackas has done a good presentation about the scope chain (I think it’s here: http://googlecode.blogspot.com/2009/06/nicholas-c-zakas-speed-up-your.html)
Otherwise, use a browser with developer tools like Chrome (Firebug often forgets what the scoped variables are).