title: How to enumerate dates between two dates in Moment
body: <p>I have two <a href="http://momentjs.com/docs/" rel="noreferrer">moment</a> dates:</p>
  
  <pre><code>var fromDate = moment(new Date('1/1/2014'));
  var toDate   = moment(new Date('6/1/2014'));
  </code></pre>
  
  <p>Does moment provide a way to enumerate all of the dates between these two dates? </p>
  
  <p>If not, is there any better solution other than to make a loop which increments the <code>fromDate</code> by 1 until it reaches the <code>toDate</code>?</p>
  
  <p><strong>Edit: Adding date enumeration method and problem</strong></p>
  
  <p>I've mocked up a method for enumerating the days between two dates, but I'm running into an issue. </p>
  
  <pre><code>  var enumerateDaysBetweenDates = function(startDate, endDate) {
      var dates = [];
  
      startDate = startDate.add(1, 'days');
  
      while(startDate.format('M/D/YYYY') !== endDate.format('M/D/YYYY')) {
        console.log(startDate.toDate());
        dates.push(startDate.toDate());
        startDate = startDate.add(1, 'days');
      }
  
      return dates;
    };
  </code></pre>
  
  <p>Take a look at the output when I run <code>enumerateDaysBetweenDates( moment(new Date('1/1/2014')), moment(new Date('1/5/2014'));</code></p>
  
  <pre><code>Thu Jan 02 2014 00:00:00 GMT-0800 (PST)
  Fri Jan 03 2014 00:00:00 GMT-0800 (PST)
  Sat Jan 04 2014 00:00:00 GMT-0800 (PST)
  [ Sun Jan 05 2014 00:00:00 GMT-0800 (PST),
    Sun Jan 05 2014 00:00:00 GMT-0800 (PST),
    Sun Jan 05 2014 00:00:00 GMT-0800 (PST) ]
  </code></pre>
  
  <p>It's console.logging the right dates, but only the final date is being added to the array. How/why is this? This smells like some sort of variable reference issue - but I'm not seeing it.</p>