title: What is the use of eval function inside Javascript?
body: <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  document.write("&lt;br /&gt;" + eval("2+2"));
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This gives me output as 4.</p>
  
  <p>If i remove the eval function and run the same thing know it gives me the same output that is 4</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  document.write("&lt;br /&gt;" + (2+2);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>