title: Iterating over a string in coffeescript without having to create an array
body: <p>I have several places in my code where I need to iterate over a string and perform operations char by char. My node.js application needs to do this dozens of times per request and often the length of the strings can be fairly long.</p>
  
  <p>The only way I've seen to convert a javascript like the one below into coffeescript is to create an array based on the length of the string. The problem with this I have is it's an extra thing to do on the hardware side, takes up extra memory, and just seems unnecessary (my node application processes dgrams - up to thousands a second - so all this extra work adds up).</p>
  
  <p><strong>The JavaScript way:</strong></p>
  
  <pre><code>for(var i = 0; i &lt; str.length; i++) { /* Do stuff with str here */ }
  </code></pre>
  
  <p><strong>The suggested CoffeeScript way</strong></p>
  
  <pre><code>for i in [0..str.length]
    # Do stuff here
  </code></pre>
  
  <p>Again, I think it's silly to force the creation of an array object when the traditional for loop doesn't have to mess with that step from a hardware perspective.</p>
  
  <p>My only work around I've found is to use while loops like:</p>
  
  <pre><code>i = 0
  while i &lt; str.length
    # Do stuff
    i++
  </code></pre>
  
  <p>While that works, that's far more verbose than even the straight JavaScript way of just using a simple for loop.</p>
  
  <p>Is there a way to use a for loop in CoffeeScript without having to generate superfluous arrays in order to perform basic iterations?</p>