title: JavaScript array not iterable
body: <p>I hit a really weird issue with a simple JavaScript array last night. I am working on a React Native app powered by Firebase and getting data from the real-time database with the SDK. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>    var app = this
  
      this.props.fb.auth().onAuthStateChanged(function(user) {
          if (user) {
              app.props.fb.database().ref('/users/' + user.uid + "/timeline").once('value').then(function(snapshot) {
                  var posts = snapshot.val()
                  return posts
              }).then((posts) =&gt; {                
                  var statuses = [];
                  for (i in posts) {
  
                      app.props.fb.database().ref('/posts/' + posts[i]).once('value').then(function(snapshot) {
                         statuses.push(snapshot.val())
                      });
                  }
  
                  console.log(statuses)
              })
          }
  
      });
  </code></pre>
  
  <p>The above code is supposed to get the data from the <code>timeline</code> of each user, iterate through each of the <code>posts</code> on the <code>timeline</code> and then get the data of the post from <code>posts</code>. It then simply pushes the data to the <code>statuses</code> array, which is being console logged at the end.</p>
  
  <p>This is what shows up on the console.
  <a href="https://i.stack.imgur.com/qWgh9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qWgh9.png" alt="enter image description here"></a></p>
  
  <p>Until the array is expanded, the console doesn't show the items in the array. Additionally, when I try to get the <code>length</code> of the array, it returns 0 and I also can't iterate through the items on the array.</p>
  
  <p>What am I doing wrong?</p>