📜  javascript 二维数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:48.252000             🧑  作者: Mango

代码示例6
var grid = [];
iMax = 3;
jMax = 2;
count = 0;

    for (let i = 0; i < iMax; i++) {
      grid[i] = [];

      for (let j = 0; j < jMax; j++) {
        grid[i][j] = count;
        count++;
      }
    }

// grid = [
//   [ 0, 1 ]
//   [ 2, 3 ]
//   [ 4, 5 ]
// ];

console.log(grid[0][2]); // 4