📜  如何在 js 中创建二维数组 - Javascript 代码示例

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

代码示例3
const m = 4;
const  n = 5;
let arr = new Array(m); // create an empty array of length n
for (var i = 0; i < m; i++) {
  arr[i] = new Array(n); // make each element an array
}
console.log(arr); //  Output: [ [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ] ]