title: Access variable from code run in "eval" in Javascript
body: <p>I know using eval is not at all recommended and I have read this link too. <a href="https://stackoverflow.com/questions/5889885/set-variable-inside-eval-javascript">Set Variable inside Eval (JavaScript)</a></p>
  
  <p>However, this is what I want to do. Lets say we have some code in a textbox. So I have to take that text, and then find out all the global variables, functions and objects in that code. 
  My idea was to wrap the code in a namespace, eval it and then iterate through the properties of the namespace to get the results. However, even though the eval runs successfully, I can't access the variable defined there. Is there a better solution or some other way to get this working. </p>
  
  <p><a href="http://jsfiddle.net/DbrEF/2/" rel="nofollow noreferrer">http://jsfiddle.net/DbrEF/2/</a> - This is the Fiddle here. </p>
  
  <p>The "var code" could actually be arbitrary code. I know its unsafe to do it but I need it for a different context. 
  Thanks</p>