删除不删除数组的位置,还有另一种删除数组位置的方法吗?
socket.on('disconnect', function () {
delete users[socket.data];
console.log(JSON.stringify(users));
socket.leave(socket.data);
});
答案 0 :(得分:1)
users.splice(socket.data, 1);
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice