views:

40

answers:

1

I do this out of habit:

function process( fn ){
  // Some process that builds data     
  return fn( data );
}

It is not always necessary to return the callback, and I would like to know if there is any performance hit in doing that over simply calling the callback:

function process( fn ){
  // Some process that builds data
  fn( data );
}

And if so, or indeed if not, then why?

+3  A: 

There is no significant performance difference between the two.

Why: Adding the return value to the stack for use by the caller is a trivial op.

As they say, it's de minimis

Larry K
And so is that answer. Nice and succinct! Thank you!
stephband