How to browse a list of javascript objects?

Asked

Viewed 665 times

0

Array de Objeto na imagem Well, I recovered this value from my firebase users node, however I am not able to recover the values, for example: name, cell phone, email.

Note: I have tried this.obj[0]. name; and return me Undefined.

  • Your question is strange, from what you can understand in the question, the question has more to do with javascript and how to use objects: see more

  • Good for your question, from to see that you have no knowledge of the Javascript language, this is not an object is a array object. You will have to go through the array to get the values contained in the object, you can do using Javascript methods as a simple for, foreach or map for example.

  • OK thank you very much, I really started to know the javascript now, sorry for the confusing question, and thank you so much for the tips

1 answer

1


There are several ways depends on what you want? as information if you want to filter by some value if you want to multiply.

the first cases are

const clients = [
  { id: 1, nome: 'Kushter 1' },
  { id: 2, nome: 'Kusther 2' },
  { id: 3, nome: 'Kusther 3' }
];

clients.forEach(item => {
   console.log(item.id, item.nome);
});

for (key in clients) {
   console.log(clients[key]);
}

See in the documentation of mozila have all the prototypes that can be used in an array just read a few minutes.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype

  • Thank you Artsher, but I still get Undefined.

  • and why you have to loop the key. in your case it will be ['VALORDATA']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.