How can I create a two dimensional array in JavaScript?

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

    ES6+, ES2015+ can do this in even simpler way


    Creating 3 x 2 Array filled with true

    [...Array(3)].map(item => Array(2).fill(true))
    

提交回复
热议问题