Function parameters
If you have a function that takes too many parameters, or parameters of the same type, then you might want to consider changing the function to take an object instead.
Consider the following function:
With such a function definition it's quite easy to invoke it incorrectly e.g. foo(flagB, flagA)
and you would get no help from the compiler.
Instead, convert the function to take an object:
Now the function calls will look like foo({flagA, flagB})
which makes it much easier to spot mistakes and code review.
Note : If your function is simple enough, and you don't expect much churn, then feel free to ignore this advice 🌹.
Last updated