javascript - What is the better way to remove the "parent index of" of an array? -
enter code hereim making nodejs application... let me show question;;
//id = dinamic string.. "user1", "user2", "userx" usersarray = []; usersarray[id]["socket"] = socket; when sockets ends, want remove [id] usersarray.. @ time id not availabe
socket.on('end', function () { ?........? socket.end(); }); how it?
there's socket.id works identifier each socket. then, can use associative array instead of usersarray:
var usersarray = {}; usersarray[socket.id] = some_user_data; you can remove entry using delete usersarray[socket.id].
Comments
Post a Comment