If you do not like the normal way of creating a two-dimensional array, for any particular reason, then this article is for you. Let me emphasize here that there's already a strong and growing need to make web pages active. So you need to start thinking about writing a custom two-dimensional JavaScript array. You will see how easy it is to do this.
You need basic knowledge of JavaScript Objects and JavaScript one-dimensional arrays to understand this series. You should also have general knowledge of arrays. In this two part series I show you how to create a custom two-dimensional array.
Rows and Columns
We shall create a two-dimensional array where the rows can be of different lengths. Most 2D arrays I have come across have rows that are all the same length. The developers of the Perl language have come up with a 2D array of different row lengths. In our custom array, let us meet this challenge.
Fig 1.1
The above table shows what we are talking about. The rows are of different lengths. They all begin from the left edge of the array table. With this array, you can talk about the height of the array, which is the number of rows.
But you can't talk about the width of the array, since the rows have different lengths. Note that the word "length" applies more to a one-dimensional quantity than to a two-dimensional one. You can talk about a maximum row length or even a minimum row length.
The rows of the array that we shall deal with in this series all begin from the left edge of the array table. The height of the array is the number of rows.