Early Returns and Callbacks: return the callback?

Having a divisive moment with my code. When doing an early return, which is preferred?

if (err) callback(err);
else {
  ...
}

or

if (err) {
   callback(err)
   return
}
...

or

if (err) return callback(err);
...

However, I'm not comfortable returning callback since it's a synchronous function. Which do you prefer? Why? Is there a technical reason as to which is preferred?

Ideally, I could do something like if (err) callback(err), return; but that's not possible.

My team and I settled on your last choice:

function (x, y, z, cb) {
  var err, data;
  ...
  if (err) return cb(err);

  ...
  return cb(err, data);
}

The reasons are pretty straight forward. One, we've settled on "cb" for our callback - the consistency is very helpful. While cb isn't returning anything it makes for an easy line to look at. EVERY TIME we use the the call back we want to make sure that we do a return because if we don't it leads to really annoying errors and "return cb(err);" is short, easy to read, consistent, removes a level of indentation, and most importantly easy to look for.

And, if you can get yourself into the habit of this or any other similar construct then it becomes second nature to look at your code and see where you have the stray "cb(err)" without the leading return.

And, BTW,

process.nextTick(function () { return cb(err); });

is more efficient than

setTimeout(function () { return cb(err); }, 0);

And keep in mind, sometimes you need the nextTick call back to unwind your stack.

And yes, we ALWAYS do a

return cb(err);

even when we don't need to. Consistency is good.

I would suggest:

if (err) {
   setTimeout(function() {
      callback(err);
   }, 0);
   return;
}

so that the callback works effectively like another thread does not interfere with the main UI thread.