Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Access Items of Two Dimensional Array in JavaScript</title> </head> <body> <script> // Sample array var arr = [ ["a", "Apple"], ["b", "Banana"], ["c", "Cat"], ]; // Accessing array elements document.write(arr[0][0] + "<br>"); // Prints: a document.write(arr[0][1] + "<br>"); // Prints: Apple document.write(arr[1][0] + "<br>"); // Prints: b document.write(arr[1][1] + "<br>"); // Prints: Banana document.write(arr[arr.length - 1][0] + "<br>"); // Prints: c document.write(arr[arr.length - 1][1]); // Prints: Cat </script> </body> </html>