I have an object named clients.
var clients = {"username" : test, "socket": asdasdkje3sf};
But I want to add some more clients. If I add an client on the following way:
clients = {
"username" : username,
"socket": socket.id
};
It gets overwritten every time I add a new value. I have tried it on this way:
clients += {
"username" : username,
"socket": socket.id
};
If I do console.log(clients)
it seems to work but it returns [object][object][object][object]
.
How can I read the objects? And is this the best approach to do this?
Thank you in advance!