I created the following 2D array in Javascript
// Create basic linear array
var ImgArray = new Array(4);
// Do the 2D array for each or the linear array slo
That's not an "enhanced for loop". You should not be iterating through Array instances that way anyway, at least not when you're treating them semantically as integer-indexed arrays.
Use your original
for (var i = 0; i < 4; ++i)
approach (and don't forget var). Also don't bother with
var ImgArray = new Array(4);
Just write
var ImgArray = [];