Creating a 2d array of objects in javascript
<p>I have a javascript object -</p>

<pre><code>cell{xPos, yPos};
</code></pre>

<p>I would like to create a 2d array of this object.</p>

<pre><code>cellPrototype = function(x, y) {
this.xPos = x;
this.yPos = y;
}
var cell = new Array();
for(var i=0;i&lt;10;i++)
{
  cell[i] = new Array();
  for(var j=0;j&lt;10;j++)
  {
     cell[i][j] = new cellPrototype(i,j);
  }
}
</code></pre>

<p>This code doesn't work.
Neither does - </p>

<pre><code>var cellPrototype = function(x, y) {    
return { 
  xPos : x;
  yPos : y;
}
var cell = new Array();
for(var i=0;i&lt;10;i++)
{
  cell[i] = new Array();
  for(var j=0;j&lt;10;j++)
  {
     cell[i][j] = new cellPrototype(i,j);
  }
}
</code></pre>

<p>So how do I create a 2d array of an object in javascript?</p>
