I was playing around with node.js and something strange happens when you run this code:
var http = require("http");
var i = 0;
function onRequest(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("You're number " + i++);
response.end();
}
http.createServer(onRequest).listen(8888);
I would expect it to behave like a page views counter, but with each refresh of the browser tab i get the result of what seems to be i=i+2
instead of a simple increment. Could someone explain this behavior to me?