What is a nested array?

In JavaScript, a nested array is an array that contains other arrays as its values or members. The container array is termed an outer array, and the member array is termed an inner array. An array is said to be a nested array if it has another array as one or more of its members, even if all other members of the outer array are not arrays.

Can you think of some instances where we might have been using a structure same as a multi-dimensional array? One such example is a crossword puzzle!

The general concepts of two-dimensional arrays, n-dimensional arrays, or jagged arrays are implemented as nested arrays in JavaScript. The following program illustrates the structure of a nested array:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy