Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

javascript - 如何在JavaScript中创建二维数组?(How can I create a two dimensional array in JavaScript?)

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 declare a 2 dimensional array in JavaScript?

    (如何在JavaScript中声明二维数组?)

    (assuming it's possible)

    ((假设有可能))

  2. How would I access its members?

    (我将如何访问其成员?)

    ( myArray[0][1] or myArray[0,1] ?)

    (( myArray[0][1]myArray[0,1]吗?))

  ask by Diego translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

 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); 


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...