var response = "Hello";
http.createServer(function (req, res) { res.end(response); });
But you do this:
response = function() { console.log('Oh no!'); };
Then the behaviour is totally different. It just sounds pretty dangerous - maybe you intended to send the function to the client as a JS file when writing the code, but actually without warning or error it executes it on the server!
Well you should never just execute any code coming from outside, that's for sure. You always have to make some sanity check on the received data.
But I agree that this syntax is kind of dirty and dangerous!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Just that if you have the following:
But you do this:
Then the behaviour is totally different. It just sounds pretty dangerous - maybe you intended to send the function to the client as a JS file when writing the code, but actually without warning or error it executes it on the server!