Attempting to grasp the concept of javascript objects and arrays, I experimented with filling and accessing an object in the following manner:
obj_keys = [1,2,3,4,5,6,7];
o = {};
$.each(obj_keys, function(k, v){
o[v] = [];
for(var c; c < 10; c++){
o[v][c] = [];
o[v][c].push([11,12,13,14]);
}
});
console.log(o);
The output is: Object { 1: Array[10], 2: Array[10], 3: Array[10], 4: Array[10], 5: Array[10], 6: Array[10], 7: Array[10] }
console.log(o[7]);
This returns: Array [ ]
console.log(o[7][8]);
It shows: undefined
console.log(o[7][8][3]);
An error appears: TypeError: o[7][8] is undefined
The question arises, why is o[v] = [ ]; acceptable, while o[v][c] = [ ]; within the loop causing issues?