title: How to get list of all variables defined in the current scope?
body: <p>I wanted to be able to get a list of all variables in the current scope. I know it may not be possible (ex. <a href="https://stackoverflow.com/q/2051678">1</a>, <a href="https://stackoverflow.com/q/11445722">2</a>, <a href="https://stackoverflow.com/q/18612198">3</a> but it would really be helpful in simplifying a parsing algorithm for a Node/browser library I'm currently working on.</p>
  
  <p>One thing: it doesn't need to be printed or safe from 'minification'.</p>
  
  <p>I was wanting to be able to figure out what variables were introduced by reading a JS library and dynamically <code>eval</code>ing it, finding the difference in state between the two. I know this approach sounds <em>terrible</em> on paper (I'm well acquainted with the hatred of eval), but if there is a better way to find this than just simply parsing the whole library (which is slow for any language other than C/etc.), I'm all ears.</p>
  
  <hr>
  
  <p>For you all right off crying over the blatant use of <code>eval</code>, I know to use closures to protect the parent scope from modification. I also will be able to prevent changes to the browser display in the eval as well if it is in a browser environment (temporarily change some DOM constructors).</p>