What is Multidimensional array in javascript?

Posted by

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

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