I am having trouble between these two bits of code. They produce different results:
thing.save()
.then(x => res.send(x))
and
thing.save()
.then(res.send)
The bottom example produces an error. I assume Express (where 'res' is used) is using '.this' behind the scenes, and the different formats are screwing with it. But why?
I guess the question is, what could the difference be between providing an arrow function with a single function call as a callback to something, versus providing just the function as the callback?
My understanding is that the arrow function would get called, and the inner function would be called in the same context that the arrow function is called. So calling the function directly would seem to be identical? That makes it seem like the two formats would act the same.