Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Is it possible to declare a 2-dimensional array in JavaScript? If yes, how to access its members?

1 Answer

0 votes
by (19.7k points)

It’s not possible to technically create a 2-dimensional array in JavaScript. But you can create an array of arrays like below:

var myArray = [

  [1, 2],

  [3, 4],

  [5, 6]

];

//To access the array items 

console.log(myArray[0][0]); // 1

console.log(myArray[0][1]); // 2

console.log(myArray[1][0]); // 3

console.log(myArray[1][1]); // 4

console.log(myArray);

If you want to learn more about Javathen go through this Java tutorial by Intellipaat for more insights. 

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Dec 30, 2020 in Python by ashely (50.2k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...