title: Is forEach() asynchronous?
body: <p>I am trying to rank a list of user based on how many times they appear in several list:</p>
  
  <pre><code>function getRegistrationsFromSportList(sportList){
          console.info('[DatabaseService-getRegistrationsFromSportList] Getting registrations to sports...');
          var promiseHash = {};
          sportList.forEach(function (sport){
            promiseHash[sport] = firebase.database().ref('/sport_registrations/' + sport).once('value');
          });
          return $q.all(promiseHash);
        }
  
        getUserSportListPromise(user.uid).then(function(sportList){
          return getRegistrationsFromSportList(sportList);
        })
        .then(function(registrationsHash){
          console.info('[DatabaseService-getMatches] Processing matches...');
          var matches = [];
          angular.forEach(registrationsHash, function(regsSnap, sport){
            console.dir(regsSnap.val());
            regsSnap.forEach(function(user){
                if (matches.indexOf(user.key) &gt; -1) {
                  matches[user.key]++;
                } else{
                  matches[user.key] = 1;
                }
                console.dir(matches);
            });
          });
        });
      }
  </code></pre>
  
  <p>Here is my console log:</p>
  
  <pre><code>Object
   e8wXuTklnVcYknc0MYn34xlcqmA3: true
  
  Array[0]
   Lvwr4lkZ58SnhrZzft6FhT08iVN2: 1
   ND9iZYJ3gfQUvjKSRaKKc8NEkAj2: 1
   SA0h1iHwyCSeytgh6FOglSf1sOs2: 1
   e8wXuTklnVcYknc0MYn34xlcqmA3: 1
  
  Object
   Lvwr4lkZ58SnhrZzft6FhT08iVN2: true
   ND9iZYJ3gfQUvjKSRaKKc8NEkAj2: true
   SA0h1iHwyCSeytgh6FOglSf1sOs2: true
   e8wXuTklnVcYknc0MYn34xlcqmA3: true
  
  Array[0]
   Lvwr4lkZ58SnhrZzft6FhT08iVN2: 1
   ND9iZYJ3gfQUvjKSRaKKc8NEkAj2: 1
   SA0h1iHwyCSeytgh6FOglSf1sOs2: 1
   e8wXuTklnVcYknc0MYn34xlcqmA3: 1
  </code></pre>
  
  <ol>
  <li>Why is my first console.info() displaying the matches array filled with the results of the second Object of regsSnap? I don't understand why this is happening while I am calling console.info() within the forEach() function</li>
  <li>I guess strongly related to point 1 but I was expecting e8wXuTklnVcYknc0MYn34xlcqmA3 to be equal to 2</li>
  <li>Why the console displays Array[0] instead of Array[3]?</li>
  </ol>
  
  <p>Any suggestion? Help?</p>
  
  <p>Thanks!</p>