Specifying one or more arguments as required is one of the common patterns in Javascript. We will see one of the ways in which we can (arguably) make it more simple.
Consider the function below -
|
|
We typically check arguments within function where necessary ..
|
|
A simpler way to accomplish the same result -
|
|
isReqd
is a single function in the module that is used by all other functions to check whether specific required arguments are provided by the caller.