node.js send to data to client?

I wonder how can I send data from node.js to client?

example node.js code -

var http = require('http');

var data = "data to send to client";

var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end("Hello World\n");
}).listen(8125);

Now, I want to send the data variable to client and log it with JavaScript..
How can I do that?

Thanks ;)

EDIT: Does anyone know how to send array?

You might want to have a look at this stackoverflow question about basic ajax send/receive with node.js here

If You Want to do it after response.end you should use Socket.io or Server Send Events.

If you want it before res.end, you would make your code look like:

var http = require('http');

var data = "data to send to client";

var server = http.createServer(function (request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write(data); // You Can Call Response.write Infinite Times BEFORE response.end
    response.end("Hello World\n");
}).listen(8125);