Given:
function foo(){
var bar = "quux";
console.log();
}
I am looking for code that when inserted into a comment will give the value bar. As an illustration, something like this works in a global scope:
var foo = "bar";
var bar = "quux";
console.log(window[foo]);
But, of course, variables defined globally are added to the window object. Variables local to the function are not. Is there a similar way to programmatically access function local variables?
source
share