In a JavaScript debugger, I can manually inspect the scope chain of a function. For instance, when executing foo()
on this piece of code:
var x1 = "global";
var foo = (function main () {
var x2 = "inside obj";
return function internalFoo () {
var x3 = "inside internalFoo";
console.log (x1+','+x2+','+x3); // get the scopes
};
})();
foo ();
and setting a breakpoint on the console.log
, I see the following scopes:
Is there some means to do this programmatically?
How can I inspect what is defined at every scope level?
Aucun commentaire:
Enregistrer un commentaire