title: assign value to an global array inside a function
body: <p>I wrote a javascript like following:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      var name = new Array();
      var i = 0;
      function doSomething() {
          name[i] = "a";
          alert(name[i]);
          i++;
      }        
  &lt;/script&gt;
  </code></pre>
  
  <p>It alerted an <code>undefined</code> instead of an <code>a</code> in my chrome. I tried to <code>alert(i)</code>, and it works very well.</p>
  
  <p>How can I assign values to a global array inside a function?</p>
  
  <hr>
  
  <p>Problem solved: I just renamed the array and it worked! But why?</p>