I'm trying to test if an array has the second dimension added. It it does I push the new record onto it, if it doesn't I add the second dimension then do the push. I've read in multiple places the way to test for the 2nd dimension being undefined, but it is not working for me. Here's the code:
if ( typeof missionData[numMissions][0] === 'undefined') {
missionData[numMissions] = [];
missionData[numMissions].push(missionRecords.record[index])
}
else {
console.log('both array dimensions exist, pushing record');
missionData[numMissions].push(missionRecords.record[index]);
}
When it executes I get the following error:
controller.js:710 Uncaught TypeError: Cannot read property '0' of undefined
Everything I've read tells me what I'm doing is correct, but obviously it is not. What am I missing?
Thanks.....