title: I am getting Error from For Loop function in Javascript
body: <p>this is a function to call SELECT element values. but i am facing an error.
  code is here.</p>
  
  <pre><code>function get_s_val(){
  var foo = all_categories_1;
  var ov1 = "";
  
      for(m=0;m&lt;=foo.length;m++){
          ov1 += foo[m].value+',';
      }
  
  console.log(ov1);
  var tme=setTimeout("get_s_val()", 1000);
  }
  get_s_val();
  </code></pre>
  
  <p>it shows an error like <code>"Uncaught TypeError: Cannot read property 'value' of undefined"</code></p>
  
  <p>but when i do some littel changes it works.. like</p>
  
  <pre><code>function get_s_val(){
  var foo = all_categories_1;
  var ov1 = "";
  
      //for(m=0;m&lt;=foo.length;m++){
          ov1 += foo[0].value+',';
      //}
  
  console.log(ov1);
  var tme=setTimeout("get_s_val()", 1000);
  }
  get_s_val();
  </code></pre>
  
  <p>i dont know that where i am wrong to write the code.</p>