title: Programmatically get values of variables local to function in javascript?
body: <p>Given:</p>
  
  <pre><code>function foo(){
    var bar = "quux";
    console.log(/*mystery code here*/);
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>var foo = "bar";
  var bar = "quux";
  console.log(window[foo]);
  </code></pre>
  
  <p>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?</p>