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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -