Cannot read property of undefined
<p>I'm looping my object data but am getting this undefined value.</p>

<p>Not sure why but was hoping some one can explain.</p>

<p>My object is like this:</p>

<pre><code>//globally set
var sdata = {"4":{"7":["1","7","3","3"]},"3":{"3":["2","8","1","1"]}};
</code></pre>

<p>And i loop the object like this:</p>

<pre><code>function is_occupied(position) {
    for (var x in sdata) {
        for (var y in sdata) {
            // error's here Cannot read property '2' of undefined
            var ex = sdata[x][y][2] &gt; position.block_width ? (sdata[x][y][2] + (sdata[x][y][2] - position.block_width)) : sdata[x][y][2],
            var ey = sdata[x][y][3] &gt; position.block_height ? (sdata[x][y][3] + (sdata[x][y][3] - position.block_height)) : sdata[x][y][3];
            if (position.x &gt;= sdata[x][y][2] &amp;&amp; position.x &lt;= ex &amp;&amp; position.y &gt;= sdata[x][y][3] &amp;&amp; position.y &lt;= ey) {
                alert('hit');
            }
        }
    }
}
</code></pre>

<p>I'm wondering why it would say its undefined ? =/ Can't work it out. Its suppose to be getting position [2] in the array data of that object. </p>
