title: Iterator and a Generator in Javascript?
body: <p>On Mozilla's page <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators" rel="noreferrer">iterators and generators</a> there is a statement:</p>
  
  <blockquote>
    <p>While custom iterators are a useful tool, their creation requires
    careful programming due to the need to explicitly maintain their
    internal state. Generators provide a powerful alternative: they allow
    you to define an iterative algorithm by writing a single function
    which can maintain its own state.</p>
  </blockquote>
  
  <p>Regarding above explanation, isn't it possible to write an iterative algorithm without Generators, such as:</p>
  
  <pre><code>Array[Symbol.iterator] = function(){
      return {
          next: function(){
              //logic
              return {
                  value: "",
                  done:false
              }
          }
      }
  }
  </code></pre>
  
  <p>Can't get my head around. Could someone explain what is the main reason they created an alternative, seems not much different to me.</p>