News for hackers. Stuff that matters.
Re:Avoid Else, Return Early (2013) by thesimon on Monday March 26, 2018 @08:27AM (#16678306)
Sort of agree, but I don't think

    if (err) {
      handleError(err)
      return
    }
and

    if (err) return handleError(err)

are equally good. The second one doesn't really make it clear wether handleError returns a value and that value is intended to be returned.
Re:Avoid Else, Return Early (2013) by timoxley on Monday March 26, 2018 @09:24AM (#16678647)
If the return value is important:

    if (err) return void handleError(err)

And in non-promise-based async JS, the return value is almost always lost/useless anyway so `return x` has no effect, might as well repurpose `return` for short-circuiting.
Re:Avoid Else, Return Early (2013) by jmull on Monday March 26, 2018 @12:12PM (#16679935)
I don't think throwing void at people is generally going to make anything clearer.
Re:Avoid Else, Return Early (2013) by timoxley on Monday March 26, 2018 @12:43PM (#16680221)
why
Re:Avoid Else, Return Early (2013) by jimmaswell on Monday March 26, 2018 @02:26PM (#16681207)
I've never seen syntax like 'if (err) return void handleError(err)' before. If I saw that in JS I'd have to look up what it meant.
Re:Avoid Else, Return Early (2013) by jmull on Monday March 26, 2018 @03:12PM (#16681583)
It’s an obscure operator. Many people are unaware of it and many of those that are have a vague notion of exactly what it does.

So people reading this code may have to stop and puzzle out this little pattern.

Here you can replace “ void “ with a new line and have code anyone with basic familiarity with a c-like language can read and understand intuitively.

Re:Avoid Else, Return Early (2013) by Forge36 on Monday March 26, 2018 @08:52AM (#16678441)
I had to double check the function call occurred. It's not intuitive and removes braces in favor of possible side effects.
Re:Avoid Else, Return Early (2013) by arghwhat on Monday March 26, 2018 @09:16AM (#16678600)
I don't think the latter is legal in most (non-JS) languages if the return value of the outer function is void.

Even if it is, I definitely agree that it should only be done if you want to communicate that handleError's return value is meaningful and should bubble up.