I need to save 2D levelmap. So should i use 2D-array or simple array and break it inside condition?
Some examples:
var map2D[3][3]={
[1 , 2 , 3 ],
[1 , 2 , 3 ],
[1 , 2 , 3 ],
}
var map[9]={
1, 2, 3,
4, 5, 6,
7, 8, 9
}
So what map is easier to read and walkthrough?
If you are trying to represent a 2D data – use a 2D array.
The performance gain/loss is negligible if any, but the READABILITY is an important factor here, and programers will most likely find it much easier to follow the logic of using 2D array for 2D space.