I have a simple check to see if a particular set of keys is an array and if not create it but for some reason the if statement returns an error, this is what I am trying to do:
//test data
var i = 0;
var map = new Array();
var Data[i]['x'] = 6;
var Data[i]['y'] = 7;
if(!map[Data[i]['x']] instanceof Array){
map[Data[i]['x']] = new Array();
}
if(!map[Data[i]['x']][Data[i]['y']] instanceof Array){ //error on this line
map[Data[i]['x']][Data[i]['y']] = new Array();
}
The error is:
Uncaught TypeError: Cannot read property '6' of undefined
This error is occuring on the second IF statement. What is the mistake I am making here?
i