I am working on a chat and using an array to hold the users. Here is my problem:
User1 joins and is given Index 0 in the array via push. User2 joins and is given Ind
Another option is to use a javascript object instead of an array.
Something like this:
var users = {};
users[1] = 'user 1';
users[2] = 'user 2';
delete users[1];
alert(users[2]); // alerts "user 2"
alert(typeof users[1]); // alerts "undefined"
You lose the array length property though, so you'll have to keep track of your max user number yourself.