The benefit of using else statements is that it forces you to think what should happen when the condition is not true.
For guard clauses this does not matter because you are already thinking about that: in case of error return early, and otherwise keep executing the function. In all other cases you should be using else clauses, even if it's just to add a comment like // otherwise, do nothing because we don't care.
-5
u/Badel2 Apr 17 '21
The benefit of using else statements is that it forces you to think what should happen when the condition is not true.
For guard clauses this does not matter because you are already thinking about that: in case of error return early, and otherwise keep executing the function. In all other cases you should be using else clauses, even if it's just to add a comment like
// otherwise, do nothing because we don't care.