var items =[[1,2,3],//this is row 0[4,5,6],//this is row 1[7,8,9]//this is row 2//cullom 0 cullom 1 cullom2]console.log(/* variable name */ items[/*row*/0][/*cullom*/0]);
const m =4;const n =5;let arr =newArray(m);// create an empty array of length nfor(var i =0; i < m; i++){
arr[i]=newArray(n);// make each element an array}console.log(arr);// Output: [ [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ] ]
// creating 1d arrayvar array =newArray(10);// add an array to each 1d element, hence creating 2d arrayfor(var i =0; i < array.length; i++){
array[i]=newArray(2);}// accessing: first element of the first roconsole.log(array[0][0]);
<script>// Create one dimensional arrayvar gfg =newArray(2);document.write("Creating 2D array <br>");// Loop to create 2D array using 1D arrayfor(var i =0; i < gfg.length; i++){
gfg[i]=newArray(2);}var h =0;// Loop to initialize 2D array elements.for(var i =0; i <2; i++){for(var j =0; j <2; j++){
gfg[i][j]= h++;}}// Loop to display the elements of 2D array. for(var i =0; i <2; i++){for(var j =0; j <2; j++){document.write(gfg[i][j]+" ");}document.write("<br>");}</script>
<script>// Create one dimensional arrayvar gfg =newArray(3);// Loop to create 2D array using 1D arraydocument.write("Creating 2D array <br>");for(var i =0; i < gfg.length; i++){
gfg[i]=[];}var h =0;var s ="GeeksforGeeks";// Loop to initialize 2D array elements.for(var i =0; i <3; i++){for(var j =0; j <3; j++){
gfg[i][j]= s[h++];}}// Loop to display the elements of 2D array.for(var i =0; i <3; i++){for(var j =0; j <3; j++){document.write(gfg[i][j]+" ");}document.write("<br>");}</script>