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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With