I'm coming from a Java background and I a way to make use of incoming data to a node.js server:
request.addListener("data", function(postDataChunk) {
postData += postDataChunk;
console.log("Received POST data chunk '"+
postDataChunk + "'.");
});
as I have seen the postData variable is allways receiving new data and adds it to the existing. My question is: every time the data event is occuring the callback function is executed, but in the way I see it, every new time the function is being called we are actually getting a new variable "postData". So I do not understand how exactlly the postData variable is actually being updated every time and not being created as a new variable as it would have been in regular Java.
Thanks.