Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html xmlns = "http://www.w3.org/1999/xhtml">
- <head>
- <title>Initializing Multidimensional Arrays</title>
- <script type = "text/javascript">
- <!--
- function start()
- {
- var array1 = [ [ 1, 2, 3 ], // first row
- [ 4, 5, 6 ] ]; // second row
- var array2 = [ [ 1, 2 ], // first row
- [ 3 ], // second row
- [ 4, 5, 6 ] ]; // third row
- outputArray( "Values in array1 by row", array1 );
- outputArray( "Values in array2 by row", array2 );
- }
- function outputArray( header, theArray )
- {
- document.writeln( "<h2>" + header + "</h2><tt>" );
- for ( var i in theArray ) {
- for ( var j in theArray[ i ] )
- document.write( theArray[ i ][ j ] + " " );
- document.writeln( "<br />" );
- }
- document.writeln( "</tt>" );
- }
- // -->
- </script>
- </head><body onload = "start()"></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement