In C#, defining a multi-dimensional array can be achieved with such a simple code:
int[,]myArray=new int[4,5];
Multi-dimensional arrays cannot be implemented through direct definition in JavaScript, so how to implement it?
First define a one-dimensional array:
var myArray= new Array();
Then define the members of the one-dimensional array as an array (redefinition is possible because JavaScript is weakly typed):
myArray[0]=new Array();
That’s it , a two-dimensional array with the first index 0 is defined. If you want to use the two-dimensional array with the first index 1, you still need to define it before use:
myArray[1]=new Array() ;
The following is an example of JavaScript multi-dimensional array application, which uses multi-dimensional arrays to store the questions and answers of multiple-choice questions:
PS: In the process of learning JavaScript recently, I often use Notepad to write programs, and then change them to .htm format to run. This is not as efficient as in VS or DreamWeaver, mainly because there are no smart prompts and highlights. But you can remind yourself to pay attention to every little detail, such as JavaScript case sensitivity, how to write Html tags, etc., haha.