How do you easily create empty matrices javascript?

前端 未结 17 1414
[愿得一人]
[愿得一人] 2020-12-04 16:29

In python, you can do this:

[([None] * 9) for x in range(9)]

and you\'ll get this:

[[None, None, None, None, None, None, No         


        
17条回答
  •  时光取名叫无心
    2020-12-04 17:01

    Well, you can create an empty 1-D array using the explicit Array constructor:

    a = new Array(9)

    To create an array of arrays, I think that you'll have to write a nested loop as Marc described.

提交回复
热议问题