title: Execute the all iterations of for loop even if some index is undefined (Javascript)(ajax)
body: <p>The problem is if for e.g <code>response[i]</code> or <code>response[i][j]</code> is undefined   the loops execution is stopped and gives this error:</p>
  
  <blockquote>
    <p>TypeError: response[i][j] is undefined.</p>
  </blockquote>
  
  <p>What i want is that all iterations of  for loops  should be executed regardless of an index is defined or not.</p>
  
  <pre><code>for (var i = 0; i &lt;= response.length; i++) {
    for (var j = 0; j &lt;= response.length; j++) {
      //  alert(response.length);
      if (response[i][j]["id"]) {
        html +=
          '&lt;option value="' +
          response[i][j]["id"] +
          '"&gt;' +
          response[i][j]["name"] +
          "&lt;/option&gt;";
        // alert(response.length);
      }
    }
  }
  </code></pre>