title: Checking a 2D Array Bounds in Javascript
body: <p>I have a 2-dimensional array that I want to check the bounds in Javascript.  I prefer doing this without checking each index independently. </p>
  
  <p>For example if my 2d array is...</p>
  
  <pre><code>dataset[row0-1][column+column0]
  </code></pre>
  
  <p>I really do not want to have to do the following...</p>
  
  <pre><code>if(row0-1 &gt;0)
  {
      if(dataset[row0-1].length &gt;= column+column0)
      {
          data = {label : dataset[row0-1][column+column0]};
      }
  }
  </code></pre>
  
  <p>The problem is that I have to first check the row and then check the column.  I prefer doing both of these checks with one operation or on one line.  Rather then returning an out of bounds error, why doesn't Javascript just return null or undefined?</p>
  
  <p>For example, in a future version of Javascript, wouldn't it be better if we could do this? </p>
  
  <pre><code>if(dataset[row0-1][column+column0] != undefined)
  {
     data = {label : dataset[row0-1][column+column0]};
  } 
  else 
  {
      ...
  }
  </code></pre>