Periodically resizing large array
From what I understand, your code only keeps at most 1000 messages. First, you need to move out 1000 to a variable and away from your logic. That way, it's visible and easily configured.

Next, there is a possibility that your list of messages will grow greater than a thousand because you only slice it off when a connection is made. What if people kept chatting, but nobody new connected? Your array will continually grow. I suggest you move that check to the "chat message" event.

Another way to do it is to just separate this slicing logic into something periodic, like run on intervals. That way, you don't have to slice every time. The drawback to this, though, is when people chat faster than you can slice off. 

Now for the logic that keeps your history in check. slice is expensive because it does a shallow copy of your array. Having a full 1000 messages in the list, if a person connects, you'd have 2 arrays of length 1000 at one moment. I suggest you use shift when the count runs over 1000. Assuming this system is only a single process, pushing in the 1001th message should immediately shift off the oldest one. Still an expensive process, but it's a lesser evil.

Lastly, to get the latest 1000 messages, it's an overhead to send 1000 events down the line to the new user individually. I suggest you create a new event that sends all 1000 at once instead of individually.

Let's try optimizing your logic:

var listOfMessages = [];
var MAX_HISTORY_LENGTH = 1000;

io.on('connection', function(socket){

  // Send down all old messages at once to this connection.
  socket.emit('new messages', listOfMessages);

  // When we recieve a message
  socket.on('chat message', function(msg){

    socket.broadcast.emit('chat message', msg);
    listOfMessages.push(msg);

    // Only splice when we need to
    if(listOfMessages.length &gt; MAX_HISTORY_LENGTH) listOfMessages.shift();

  });
});