I will make the design simple. The aim of this series is to show you how you can create your own custom array and not to show you how to create a supper array.
We shall see how to define the following properties and methods:
height: Number of rows in the array.
insertRow: to insert a row in the array.
deleteRow: to delete a row.
I will show you how to add more properties and methods at the end of this two-part series.
Second, you can use object initializers to create objects.
So, our two-dimensional array will be an object where we shall emphasize its array characteristics.
You can create objects using an object initializer. Using object initializers is sometimes referred to as creating objects with literal notation.
The syntax for creating an object using an object initializer is:
where objectName is the name of the new object, each property I is an identifier (either a name, a number, or a string literal), and each value I is an expression whose value is assigned to the property I. The objectName and assignment is optional. If you do not need to refer to this object elsewhere, you do not need to assign it to a variable.