BTW, the return in case B is ignored and not needed. On Tue, Apr 10, 2012 at 4:24 PM, Mark Hahn <m...@hahnca.com> wrote:
> The only difference is that the return value of foo takes on the > callback's return value instead of null. There is no other difference at > all. > > > On Tue, Apr 10, 2012 at 4:17 PM, Ken <ken.woodr...@gmail.com> wrote: > >> Assuming that the callback doesn't return a value, does v8 behave any >> differently when invoking callbacks in one of these forms vs. the other? I >> find the first approach to be a convenient shorthand in many cases, but am >> wondering (after observing some unexpected timings when profiling async >> methods) if it leads to v8 doing something odd with the stack. >> >> Approach A, return the invoked callback: >> >> function foo(a, callback) { >> var bar = ...; >> return callback(bar); >> } >> >> foo("derp", function(b) { ...; return; }); >> >> Approach B, invoke callback, then return: >> >> function foo(a, callback) { >> var bar = ...; >> callback(bar); >> return; >> } >> >> foo("derp", function(b) { ...; return; }); >> >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to nodejs@googlegroups.com >> To unsubscribe from this group, send email to >> nodejs+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en