Pass data from server to client side

I have now;

io.sockets.on('connection', function(){
 var test = 'test';
 console.log(test);
});

this will showed up on the server, but how do i get this variable at the client side ?

You would better read the Socket.io docs. There are very good examples which you can use in a straightforward fashion.

The server code:

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event from client', function (data) {
    // This will print to the console of your server app.
    console.log(data);
  });
});

The client code:

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io();
  socket.on('news', function (data) {
    // This will print to the console of your browser.
    console.log(data);
    socket.emit('my other event from client', { my: 'data' });
  });
</script>

Basically, you should call emit() to send data to the client. The console.log() is an internal function which will print the data to the console of your server app. It doesn't send any data to the client.