title: create multiple 2 d arrays of objects using javascript where object has same properties
body: <p>How can I create two 2-DArrays where each element of array is an object with properties . Both arrays are of different size and property of each cell is different. </p>
  
  <pre><code>var gridcell = [];
  var regionalcell = [];
  </code></pre>
  
  <p>So far I have done this, It works but its not efficient i dont want to repeat the code. It would be great if you guys can help.</p>
  
  <p>In both functions value of "w,h,r,c" is different.</p>
  
  <pre><code>function createCellArray(w, h,r,c) 
  {
       for (j = 0; j &lt; r; j++) 
       {
           gridcell[j] = [];
         for (i = 0; i &lt; c; i++) 
         {
           gridcell[j][i] = 
              {
                   "x1": w * i,
                   "y1": h * j,
                   "x2": w * (i + 1),
                   "cell_color": null,
                   "y2": h * (j + 1),
                   "name": (i + 1 * (j * 10)) + 1
              }
          }
       }
  }
  
  
  function createRegionalCellArray(w, h, r, c) {
      for (j = 0; j &lt; r; j++) {
          regional[j] = [];
          for (i = 0; i &lt; c; i++) {
              regional[j][i] =
              {
                  "x1": w * i,
                  "y1": h * j,
                  "x2": w * (i + 1),
                  "cell_color": null,
                  "y2": h * (j + 1),
                  "name": (i + 1 * (j * 10)) + 1
              }
          }
      }
  }
  </code></pre>