

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Split one-dimensional array into two-dimensional array JavaScript
- Transpose of a two-dimensional array - JavaScript
- How to create JTable from two dimensional array in Java?
- Java Program to create DefaultTableModel from two dimensional array
- How to declare a two-dimensional array in C#
- Passing two dimensional array to a C++ function
- Create new instance of a Two-Dimensional array with Java Reflection Method
- How to split comma and semicolon separated string into a two-dimensional array in JavaScript ?
- Alternating sum of elements of a two-dimensional array using JavaScript
- Create a two-dimensional array with the flattened input as a diagonal in Numpy
- How do I sort a two-dimensional array in C#
- Creating a two-dimensional array with given width and height in JavaScript
- C# program to Loop over a two dimensional array
- How to form a two-dimensional array with given width (columns) and height (rows) in JavaScript ?
- Multi-Dimensional Array in Javascript
Advertisements