If you are trying to access the values, you can use the keys attribute
var myFireBaseObj = {
"users" :
{
"GSIgfyiEGtZs5reYe4SpwFJVxDC2" :
{
"email" : "anic@hotmail.com",
"password" : "Dava123",
"score" : 0,
"username" : "Anic2",
"zdate" : "2-3"
},
"OHxA5ARnbYdsy9Ga1nxDy0gZQBv1" : {
"email" : "dava@hotmail.com",
"password" : "Dava123",
"score" : 3,
"username" : "dava",
"zdate" : "01-03-2021 11:53"
}
}
};
console.log( Object.keys(myFireBaseObj));
// if you want to get both values and keys / users etc seperately as objects
var keys = Object.keys(myFireBaseObj );
var values = Object.values(myFireBaseObj );
console.log(keys[0]);
// put your attribute you want here
console.log(values [0]['...']);
Option 2: if you want an array back, use map
for e.g. adapt it below
Object.keys(myFireBaseObj).map(function(a,i){
// whatever you want in the array you map it here
// you have to customize the nested levels
return
[i,myFireBaseObj[a].blahBlah.. ,
myFireBaseObj[a].password]
})
Update: Added sample to show for loop
to get the key
, values
for (var key of Object.keys(myFireBaseObj)) {
// this will give you the key & values for all properties
console.log(key + " -> " + p[key])
// .. process the data here!
}