I avoid boolean function arguments
I avoid boolean function arguments. Here’s why.
🚩 They’re hard to read.
🚩 They infer the function does two different things
Here's two common examples, with solutions.
Example 1 - Hard to read:
Example 2 - Does two things:
In both cases, the code reads more clearly.


A third option I forgot to mention: accept an object.
savePurchase({emailReceipt: true});
Now the Boolean reads well.
Handy with optional args or multiple args too.