我对如何在 javascript 中创建和访问二维数组感到困惑。下面是一个数组声明,我在其中存储人的姓名,然后是他们图像的 src。当我尝试访问 myArray[0][0] 元素时,我得到“D”,当我尝试访问 myArray[0,0] 时,我得到唐老鸭。如何访问 img src myArray[0][0] = "assets/scrybe.jpg" ?
JS代码:
var myArray = new Array(1);
myArray[0] = "Donald Duck";
myArray[1] = "Winnie Pooh";
myArray[2] = "Komal Waseem";
myArray[3] = "Hockey";
myArray[4] = "Basketball";
myArray[5] = "Shooting";
myArray[6] = "Mickey Mouse";
myArray[0][0] = "assets/scrybe.jpg";
myArray[1][0] = "assets/scrybe.jpg";
myArray[2][0] = "assets/scrybe.jpg";
myArray[3][0] = "assets/scrybe.jpg";
myArray[4][0] = "assets/scrybe.jpg";
myArray[5][0] = "assets/scrybe.jpg";
myArray[6][0] = "assets/scrybe.jpg";