I'm looking at an array problem that I'm having trouble understanding how the values are being passed in the for loop:
var a = [ [ 1, 2 ], [ 3, 4] ];
a[ 1 ][ 1 ] = 5;
for ( var row = 0; row < a.length; row++ )
{
for ( var col = 0; col < a[ 0 ].length; col++ )
document.write( a[ row ][ col ] + " " );
document.write( "<br />" );
Running the program I see: 1 2 3 5
Are [ [ 1, 2 ], [ 3, 4] ] two separate arrays or one belonging to var a? I can see the first part of the array [ [ 1, 2 ] is being passed and printed, what happens to the second part?
***Sorry total newbie I'm just looking for a better explanation of arrays. Thanks you!