Sending object from node server to javascript on client side
<p>I have a very simple server like this:</p>

<pre><code>var http = require('http');
var fs = require('fs');

http.createServer(function (req, res) {

  res.writeHead(200, { 'Content-Type': 'text/html' });
  fs.readFile('index.html', 'utf-8', function (err, content) {
    if (err) {
      res.end('something went wrong.');
      return;
    }
    res.end(content);
  });

}).listen(8080);
console.log("Server running on port 8080.")
</code></pre>

<p>This takes care of rendering my html, but now I want to send an object. Something like this:</p>

<pre><code>var arr = [1,2,3];
</code></pre>

<p>I want to be able to manipulate this object on the client side using js. So in addition to knowing how to send it from server to client, I would like to know how to receive it in the client, if that makes sense. </p>

<p>I am trying to learn how things happen behind the scene so I do not want to use express. </p>