title: I can only add three elements to two-dimensional array, instead of four
body: <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset=utf-8 /&gt;
  &lt;title&gt;&lt;/title&gt;
    &lt;script type="text/javascript"&gt;
       function arr(){
       var a=new Array(new Array());
       var x;
       for(i=0;i&lt;2;i++)
       {
           for(j=0;j&lt;2;j++)
           {
               x=prompt("Enter an element for a["+i+"]["+j+"]"," ");
               a[i][j]=x;
           }
       }
  
       for(i=0;i&lt;2;i++)
       {
           for(j=0;j&lt;2;j++)
           {
              document.write(a[i][j]);
           }
       }
  
       document.close();
  
       }
  
  
       &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body onLoad="arr();"&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The code above was tested on Firefox. Only three prompts are displayed, instead of four:</p>
  
  <pre><code>a[0][0]
  a[0][1]
  a[1][0]
  </code></pre>
  
  <p>The array is also not printed. What's my mistake? How to fix this?</p>