1
I’m having some problems with Objects while using them in Node js , I need an object like this :
var clients = {};
var user = {
[client.id] : {
'nome': 'osvaldo',
'sala': 'B1'
}
};
clients.push(user);
However as I am using Node , I need to take these values dynamically by index( que é o [client.id]), remembering that the data are inserted dynamically and consumed also dynamically, and the way to get a value of this Object would be:
user.[client.id].nome
Any idea how to fix this ? client.id is the socket-generated ID
Friend, it was not clear what is your problem. And about Arrays... your code has no Array, only objects.
– Gabriel Katakura
Our ... thousand excuses I will edit , I researched so much the whole day that I had array in my head
– Osvaldo Pereira
No problem... I believe the @bfavaretto answer is what you want.
– Gabriel Katakura