title: Socket.IO node js saving data to client
body: <p>currently I want to save an int assigned from the server to my client</p>
  
  <p>server side: </p>
  
  <pre><code>socket.emit('clientId', id);
  </code></pre>
  
  <p>Client Side:</p>
  
  <pre><code>var clientId;
  socket.on('clientId', function(data){
       clientId = data;
  });
  </code></pre>
  
  <p>however, when I use console.log(clientId); outside the function, it becomes undefined. Is there a solution to this. Thanks</p>