title: Different output of Closure JavaScript (simple) counter
body: <p>Can someone explain me this different output of closure JS counter please.</p>
  
  <p><strong>First snippet</strong> <em>where output starts from 0:</em></p>
  
  <pre><code>var counter = (function() {
      var count = 0;
      return function() {
          return count++;
      }
  }());
  console.log(counter()); // output: 0
  console.log(counter()); // output: 1
  console.log(counter()); // output: 2
  </code></pre>
  
  <p><strong>Second snippet</strong> <em>where output starts from 1:</em></p>
  
  <pre><code>var add = (function() {
      var counter = 0;
      return function() {
          counter++;
          return counter;
      }
  })();
  
  console.log(add()); // output: 1;
  console.log(add()); // output: 2;
  console.log(add()); // output: 3;
  </code></pre>
  
  <p>Why does it work like that way? Why first output starts from 0, and second one from 1? Thanks.</p>