0

I have declare array out side of arrow function then pushing values in it inside arrow function but that array is only available inside of arrow function outside of it array is empty.

 var listings = [];
  

  
  dbRef.on("value", (snapshot) => {
    snapshot.forEach((listing) => {
    
      listings.push(listing.val());
    });
  
  
  });

  console.log('listing',listings);

console log display array value only inside of arrow function, what could be the reason

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Saad Ramay
  • 152
  • 1
  • 11

0 Answers0