How can I create a two dimensional array in JavaScript?

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

    var items = [
      [1, 2],
      [3, 4],
      [5, 6]
    ];
    console.log(items[0][0]); // 1
    console.log(items[0][1]); // 2
    console.log(items[1][0]); // 3
    console.log(items[1][1]); // 4
    console.log(items);

提交回复
热议问题