- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a two dimensional array in JavaScript?
A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. To create a two-dimensional array in JavaScript, you can try to run the following code −
Example
<html> <body> <script> var myarray=new Array(3); for (i=0; i <3; i++) myarray[i]=new Array(3) myarray[0][0]="One" myarray[0][1]="Two" myarray[0][2]="Three" myarray[1][0]="Four" myarray[1][1]="Five" myarray[1][2]="Six" myarray[2][0]="Seven" myarray[2][1]="Eight" myarray[2][2]="Nine" document.write(myarray[2][0]); </script> </body> </html>
Output
Seven
Advertisements
To Continue Learning Please Login
Login with Google