Congratulations! You already created a valid example. Your
dd
is the array of 1 element, which is the object with two properties,
data1
and
data2
, each of them are the arrays with 5 integer elements.
Now, note that in Javascript the array and record/structure objects are the same, only the initialization syntax is different, but you can use both ways of indexing on objects. For example,
data1
can be referred as
dd[0].data1
or
dd[0]["data1"]
. Any object can serve as the index. Javascript object are actually
associated containers. Please see:
http://en.wikipedia.org/wiki/Javascript#Dynamic[
^],
http://en.wikipedia.org/wiki/Associative_array[
^].
When your object is initialized as such associated container (array), you can always add any new key/value pair, no matter of what types:
dd[0].data1["someIndex"] = "some value";
—SA