Issue:
An error has occurred - Uncaught TypeError: Cannot set property '0' of undefined
Snippet of relevant code:
var field = new Array(6);
for(var x=0; x<field.length; x++){
field[x] = new Array(12);
for(var y=0; y<field[x].length; y++){
field[x][y]= new tile();
field[x][y].type = Math.floor(Math.random()*7);
field[x][y].subtype[0]=false;//error occurs when this line is executed
field[x][y].subtype[1]=false;
field[x][y].subtype[2]=false;
field[x][y].subtype[3]=false;
}
}
function tile() {
var type = 0; type = 0;//int
var subtype = new Array(4);//Boolean
//+ some functions
}
I am aware that something crucial is missing in the code, but I'm unable to pinpoint it. Can anyone provide assistance?
Update: Additionally, an "Uncaught SyntaxError: Unexpected token this" error was encountered when attempting to add "this." before 'type' and 'subtype' in the tile object. The mistake was due to mistakenly typing
var this.
//instead of
this.