How can I create a two dimensional array in JavaScript?

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

    Two dimensional arrays are created the same way single dimensional arrays are. And you access them like array[0][1].

    var arr = [1, 2, [3, 4], 5];
    
    alert (arr[2][1]); //alerts "4"
    

提交回复
热议问题