Not sure if they are still supported in NodeJS, but if so, you can also easily use the arrow functions.
app.get('/sites', function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); dbaccess.exec(query, r => writeResponse(res, r)) });
They also preserve the lexical meaning of this , which is nice if necessary.
This is roughly equivalent to this:
app.get('/sites', function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); dbaccess.exec(query, function(r) { return writeResponse(res, r); }) });
although it has this defined by .exec() .
user1106925
source share