why is this javascript array undefined?
<p>I have the following code, which attempts to generate a 2 dimensional array of random numbers:</p>

<pre><code>var block_size = 32;
var can_width = can.width;
var color_depth = 12;
var passes = can_width / block_size;
var map_store = new Array(passes);

for(i=0;i&lt;passes;i++) {
  for(j=0;j&lt;passes;j++) {
    map_store[i] = new Array(passes);
    color = Math.random() * color_depth;
    map_store[i][j] = Math.round(color);
  }
}
</code></pre>

<p>which seems to work fine if i put <code>console.log</code> statements within the loop, however if I try to access the <code>map_store</code> array outside of the loops. all of it's elements are undefined. why is this?</p>
