title: Is there a mechanism to loop x times in ES6 (ECMAScript 6) without mutable variables?
body: <p>The typical way to loop <code>x</code> times in JavaScript is:</p>
  
  <pre><code>for (var i = 0; i &lt; x; i++)
    doStuff(i);
  </code></pre>
  
  <p>But I don't want to use the <code>++</code> operator or have any mutable variables at all. So is there a way, in ES6, to loop <code>x</code> times another way? I love Ruby's mechanism:</p>
  
  <pre><code>x.times do |i|
    do_stuff(i)
  end
  </code></pre>
  
  <p>Anything similar in JavaScript/ES6? I could kind of cheat and make my own generator:</p>
  
  <pre><code>function* times(x) {
    for (var i = 0; i &lt; x; i++)
      yield i;
  }
  
  for (var i of times(5)) {
    console.log(i);
  }
  </code></pre>
  
  <p>Of course I'm still using <code>i++</code>. At least it's out of sight :), but I'm hoping there's a better mechanism in ES6.</p>