javascript - Delete JSON data in array -


i trying remove piece of data json array. example, have array;

var users = []; io.on('connection',function(socket){    socket.on('nickname', function(nick){       socket.nick = nick;        users.push({          user:socket.nick,          userid:socket.id,          socket:socket        });     }); 

i trying delete in users way;

socket.on('disconnect', function(){     delete users[{         user,         userid,         socket     }];    });  }); 

how can that?

you may try using lodash methods achieve trying to: -

var _ = require('lodash'); socket.on('disconnect', function(){         _.pullallwith(users, [{              user:socket.nick,              userid:socket.id,              socket:socket              }], _.isequal)        });      }); 

see if works..


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -