Multi-Dimensional Arrays


A multi-dimensional array is an array that contains other arrays inside it. It is mainly used to store data in rows and columns, similar to a table.

For example, a list of students with their marks, or a grid in a game, can be stored using multi-dimensional arrays.

Learning multi-dimensional arrays helps students work with structured data in real-world applications.

Where Multi-Dimensional Arrays Are Used

  • Storing table data  
  • Representing rows and columns
  • Game boards and grids
  • Student marks and reports
  • Matrix calculations  

They help manage complex data in an organized way.

Here, marks is a two-dimensional array.  

Each inner array represents one student’s marks.

This structure is useful when working with grouped data.

To access values in a multi-dimensional array, you use two indexes.

The first index selects the row.  

The second index selects the column.

This example shows how nested loops are used to process multi-dimensional arrays.

By mastering multi-dimensional arrays, students gain the ability to work with complex data structures and build advanced, real-world JavaScript applications.