How to loop throw array of objects?

i have this array of objects that came from firebase
image

when i used this all method nothing appear on the console
1- using foreach

    this.ObjectArray.forEach(Data => {
        console.log(Data["Name"]);
    });

2- using index

console.log(ObjectArray[0].Name);

idon’t know why nothing appear to the console
but my problem is that i want to fetch a list of data from firebase google cloud and then loop throw this list

thanks in advance

How are you getting the data? I’m not sure if it’s relevant, but it seems to think that it’s an empty array perhaps with properties named 0 and 1.

Minor note, but I’d also suggest using lowerCamelCase for property names as it’s standard.

this how i’m getting data from firebase

    let charites = [{Key : '' , Name : ''  , Description : ''  ,Points :''}];
    firebase.database().ref('/charites/').on("value", (snapshot) => {
      snapshot.forEach((snap) => {
        charites.push({
          Key: snap.key,
          Name: snap.val().Name,
          Description: snap.val().Description,
          Points: snap.val().Points
        });
        return false;
      });
    });
    return charites;
1 Like