title: JS- textarea lines to javascript array
body: <p>I want save textarea lines in js array.
  this code works but if we have empty line in textarea, array elements values set undefined after empty line!
  <br />DEMO: <a href="http://jsfiddle.net/pYTjR/3/" rel="nofollow">http://jsfiddle.net/pYTjR/3/</a></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function check(){
  var lines = $('#links').val().split(/\n/);
  var texts = []
  for (var i=0; i &lt; lines.length; i++) {
  
    if (/\S/.test(lines[i])) {
      texts.push($.trim(lines[i]));
      }
  var links = texts;
  var str = links[i];
  alert(i+"-  "+str);
  }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;textarea id="links" name="upload" cols=80 rows=10&gt;
  www.example.com/book111.pdf
  www.example.com/book222.pdf
  www.example.com/book333.pdf
  
  www.example.com/book444.pdf
  www.example.com/book555.pdf
  &lt;/textarea&gt;
  
  &lt;input type="submit" id="getsize" name="getsize" value="textarea to array" onclick= "check()" /&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>DEMO: <a href="http://jsfiddle.net/pYTjR/3/" rel="nofollow">http://jsfiddle.net/pYTjR/3/</a></p>