Often times I find myself writing functions which have optional args, while it’s generally a better idea to pass an options object instead for mutliple arguments, three (maybe four) can still be considered an acceptable arity.
Let’s take a simple signature and implement some optional args.
1
|
|
The way I started to deal with cases like this is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
I find this the clearest way to deal with optional args and I find the logic very easy to follow.