Table of Contents
Back Button
Back to Chapter
Control Statements
No items found.
Function & Events
No items found.
Array and its Types
No items found.
OOP : Object Oriented Programming
No items found.
Javascript Standards
No items found.
No items found.
Javascript : Advanced 1
No items found.
Javascript : Advanced 2
No items found.
Additional JavaScript
No items found.

Multi - Dimensional Array


Multidimensional array is an array, which contains one or more arrays.

Multi-Dimensional Array Declaration


var arrayName = [['value','value',...],['value','value',...],['value','value',...],....];

We can declare 2-Dimenesional, 3-Dimensional and any No. of Dimensional array.


We are Creating a Array, Which stores the Name, Age and Gender of 3 peoples.

var identity = [['Sam','25','Male'],['Jatin','19','Male'],['Kirti','23','Female']];

In this way, Arrays with unique index are declared.

Accessing The Multi-Dimensional Array Elements

To Access or Print Element in Array, We should know the Index of Element.




Inside Square Brackets Index of the Element should be placed.

Let's Understand How to Find The Index of Multi-Dimensional Array :

For Example : If it is 2-Dimensional Array, Then you should imagine

2-D Dimensional Array

For Example : If it is 3-Dimensional Array, Then you should imagine

3-D Dimensional Array


var identity = [['Sam','25','Male'],['Jatin','19','Male'],['Kirti','23','Female']]; console.log(identity[0][0]); console.log(identity[0][1]); console.log(identity[0][2]); console.log(identity[1][0]); console.log(identity[1][1]); console.log(identity[1][2]); console.log(identity[2][0]); console.log(identity[2][1]); console.log(identity[2][2]); // Output // Sam // 25 // Male // Jatin // 19 // Male // Kirti // 23 // Female

Now Try to Visualize This 3-D Dimensional Array.

Copy of 3-D Dimensional Array

Iteration Through Multi Dimensional Array

We, will be using Nested for Loop.

Printing All Elements of Multi-Dimensional Array.

var identity = [['Sam','25','Male'],['Jatin','19','Male'],['Kirti','23','Female']]; var totalLength = identity.length; //2 var i; for(i=0;i
Ask queries
Contact Us on Whatsapp
Hi, How Can We Help You?