title: Storing a Minecraft-like map as a JavaScript array
body: <p>I'm writing a map editor that converts a 3D space into JavaScript arrays so that it can be exported to a JSON file.</p>
  
  <p>Each map will have a 2D plane acting as a ground layer (the user will have to specify X and Y size), then to add height, the user can place blocks on top of this 2D plane, following a X &amp; Y grid (similar to <em>Minecraft</em>).</p>
  
  <p>My idea was to have an array for each Z layer, and fill it with the information about which blocks are placed there. Because the X and Y sizes of the map must be specified, a simple array should do the trick, as to read the map you would simply loop for each Z layer array and fill the map with its contents, which would be another array. Creating rows defined by the X and Y size of the ground layer.</p>
  
  <p>I know you can fill arrays like <code>layer[165] = grassBlock</code>
  after you declare them, Which would make everything before index 165 empty and thus save space. But in a JSON format, wouldn't that array have 164 zeroes or nulls before it reaches this index?</p>
  
  <p>Is this even the most efficient way to store a 3D space? I'm trying to minimize map size and speed up load time as much as possible.</p>