What is Multidimensional array in javascript?

Posted by

multidimensional arrays in JavaScript is known as arrays inside another array. We need to put some arrays inside an array, then the total thing is working like a multidimensional array. The array, in which the other arrays are going to insert, that array is use as the multidimensional array in our code. 

syntax

array name[
            [1st dimension],
            [2nd dimension],
            [3rd dimension],
            .
            .
            [Nth dimension] 
          ];

example

<!DOCTYPE html>
<html>
<head>
		<title> alert in javascript</title>
</head>
<body>
		<script>
		var array=[
					["shivani",  "female" ,"20"],
					["ravi",  "male",  "18"],
					["abhiprit"  ,"male",  "30"],
					["omprakash", "male", "12"],
					["khushbu",  "female",  "22"],
					["shiv", "male",  "20"]
				  ];
		
		for(var a=0; a<6; a++)
		{
		document.write(array[a] + "<br>");
		}
		
		</script>

</body>
</html>

output

shivani,female,20
ravi,male,18
abhiprit,male,30
omprakash,male,12
khushbu,female,22
shiv,male,20
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x