Q:

Why won't the event trigger when I emit with socket?

I have an event I am trying to trigger that's called 'usernames'.
I am using the Socket.IO library in Node.js. So I have 2 files, index.html and server.js:
The event I am trying to emit is on the client side in index.html:
    //show online users
    socket.on('usernames', function (data) {
        console.log('@@@@@@@@@@@@@@@@@@@@@');
        var html = '';
        for (var i = 0; i < data.length() ; i++) {
            html += data[i] + '<br/>';
        }

        $users.html(html);
    });

The emit is on the server side in server.js : 
io.sockets.on('connection', function (socket) {
    //new user join
    socket.on('new user', function (data, callback) {
        if (nicknames.indexOf(data) != -1) { //if name dont exist .indexOf() returns -1
            callback(false);
        } else {
            callback(true);
            socket.nickname = data;
            nicknames.push(socket.nickname);
            io.sockets.emit('usernames', nicknames);
        }
    });
     // sent message from user
    socket.on('send message', function (data) {
        //send the data to all users
        io.sockets.emit('new message', data);
    });
    //
});

**The event in index.html is inside $(document).ready(); 
Nothing happens, the event won't trigger.
Help ? 

A:

Answering my own question. 
There were 2 errors:
1) The statement 'data.length()' didn't compile, the correct way is using 'data.length'.
2) I didn't fire 'new user' event hence the 'usernames' event didn't trigger.

