send actually a function of the res object. He tries to use other data from the object res . But when you do
var cb = res.send; cb({...});
you simply use the send function object without reference to the res object. That is why it does not work.
If you ever need to do something like this, bind the res object to a send function like this
var cb = res.send.bind(res);
Now
cb({...});
will also work. Since res bound to the send function object, and the resulting function is stored in cb .
The bind function is actually Function.prototype.bind
source share