title: NodeJS - Creating empty array results in array with a lot of nulls
body: <p>I am creating a Node.js chat using socket.io<br>
  The problem is that when I see the <code>console.log</code> of <code>history</code> I see an array with A LOT of nulls and at the end my history entries
  <code>[null,null,null......[ { username: 'Nobody Example', message: '231', date: '03/21/2013 14:23:58' } ]]</code></p>
  
  <p>How come these nulls are in the array?<br>
  Here is a part of my code. </p>
  
  <pre><code>var history = [];
  
  io.sockets.on('connection', function (socket) {
  
      socket.on('send', function (message) {
          var date = time();
  
          io.sockets.in(socket.room).emit('message', socket.username, message, date);
  
          history[socket.room].push({ username: socket.username, message: message, date: date });
  
          console.log(history);
  
      });
  
      socket.on('joinroom', function (room, username) {
          socket.room = room;
          socket.join(room);
  
          if ( typeof history[room] === 'undefined' )
              history[room] = [];
  
      });
  
  });
  </code></pre>
  
  <p>Edit for more details:</p>
  
  <p>The problem is in the 'joinroom' event when creating the empty array for each room.<br>
  Here are few tests that I've made:</p>
  
  <pre><code>socket.on('joinroom', function (room, username) {
      socket.room = room;
      socket.join(room);
  
      console.log(typeof history[room] == 'undefined');
      history[room] = [];
      console.log(typeof history[room] == 'undefined');
      console.log(JSON.stringify(history));
  });
  </code></pre>
  
  <p>The console logs: </p>
  
  <pre>true
  false
  [null,null,null,null,..................,null,[]]</pre>