Why is my function not executiong my global variable?
<pre><code>&lt;script type="text/javascript"&gt;

  var number = "10";

  (function(){
    alert(number);    
    alert(eval('number=22'));

  })();

  var func = function() {
      alert (new Function( 'return (' + number + ')' )());
  }

  func(); // prints 22.

&lt;/script&gt;
</code></pre>

<p>It first alerts <code>10</code>, then alerts <code>22</code> then why is it alerting <code>22 again instead of 10</code>. Does eval function overrides my variable in global scope.</p>
