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.
HTML DOM
No items found.
No items found.
No items found.
No items found.

# Multi - Dimensional Array

## Introduction

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

## Multi-Dimensional Array Declaration

### Syntax

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

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

### Example

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.

### Syntax

``` arrayName[rowNumber][columnNumber]; ```

Here,

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

Example:

``` 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```
`Menu`
`HomeCoursesEventsCampus Ambassador Program`
`About`
`About UsPrivacy PolicyTerms and ConditionsCancellation and Refund PolicyContact UsCareers`
`Courses`
`Data Scientist Industrial Training Program`
`Full-Stack Web Dev Industrial Training Program`
`DevTown Bytes`
`RoadmapsCheatsheetsVideosBlogs`
``` ```
``` ```
``` Contact Us Contact Us on WhatsappHi, How Can We Help You? ```