I'm a bit new with Javascript and I'm trying to create objects with arrays inside. In C I have sort it out easily using structs, but in Javascript I'm a little bit lost. Here's my code:
function Switch() {
var title;
var toggleModeEnable;
};
function Layer () {
sw = [8];
for (j = 0; j < 8; j++) {
sw[j] = new Switch();
};
};
var lr = [10];
for (i = 0; i < 10; i++) {
lr[i] = new Layer();
};
Obviously, this doesn't work. What I'm trying to achieve is having an array (lr) of 10 elements. Each of them should be an ayyay of 8 elements (sw), and each one with two properties (title and toggleModeEnable), and access them with something like this:
lr[1].sw[3].title
But something like this throws an error like:
"Uncaught TypeError: Cannot read property '3' of undefined at :1:9"
What I'm missing here?