How can I create a two dimensional array in JavaScript?

后端 未结 30 4395
天涯浪人
天涯浪人 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:51

    Two-liner:

    var a = []; 
    while(a.push([]) < 10);
    

    It will generate an array a of the length 10, filled with arrays. (Push adds an element to an array and returns the new length)

提交回复
热议问题