title: How to read file content in a javascript variable?
body: <p>I got a small script to split the text inside 'var foo' after every 4 characters. It is working fine.
  but my actual data is in a text file say 'a.txt'. How do I take this entire file text in 'var foo'. and write the split output to another text file?</p>
  
  <pre><code>var foo = "this is sample text !!!"; 
  var arr = [];
  for (var i = 0; i &lt; foo.length; i++) {
      if (i % 4 == 0 &amp;&amp; i != 0)
          arr.push(foo.substring(i - 4, i));
      if (i == foo.length - 1)
          arr.push(foo.substring(i - (i % 4), i+1));          
  }
  document.write(arr);
  console.log(arr);
  </code></pre>