title: TypeError: foo is undefined when trying to call it in array
body: <p>I have this small method.</p>
  
  <pre><code>$cargos = JSON.parse('&lt;?php echo $cargos ?&gt;');
  $html = '';
  
  console.log($cargos[0][0]); //correct printing of the desired values
  
  for(var x=0;x &lt;= $cargos.length;x++)
  {
     console.log(x); //this prints the numbers correctly
     $html += "&lt;option value='"+$cargos[x][0]+"'&gt;"+$cargos[x][1]+"&lt;/option&gt;"; //error, $cargos[x] is undefined
  }
  </code></pre>
  
  <p>I'm retrieving a (multidimentional) array from PHP using JSON, and I plan to do a small loop with it however I can't use the variable <code>x</code> when calling the array elements because I get an error.</p>
  
  <pre><code>TypeError: $cargos[x] is undefined
  </code></pre>
  
  <p>If I try to call the indexes manually using numbers they print correctly without errors.</p>
  
  <p>What am I doing wrong?</p>