Given:
function foo(){ var bar = 'quux'; console.log(/*mystery code here*/); }
I’m looking for code that when inserted into the comment would yield the value of bar. By way of 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 appended to the window object. Variables local to a function are not. Is there some similar way to programmatically get to local function variables?
Nope, afraid not.
See: javascript locals()?