How can I create a two dimensional array in JavaScript?

后端 未结 30 4292
天涯浪人
天涯浪人 2020-11-21 05:25

I have been reading online and some places say it isn\'t possible, some say it is and then give an example and others refute the example, etc.

  1. How do I dec

30条回答
  •  长情又很酷
    2020-11-21 05:31

    Below one, creates a 5x5 matrix and fill them with null

    var md = [];
    for(var i=0; i<5; i++) {
        md.push(new Array(5).fill(null));
    }
    
    console.log(md);

提交回复
热议问题