Named parameters are a handy feature that have existed in other loosely typed languages such as Python for some time. With the feature called
destructuring assignment available in newer versions of Node.js, we gain the ability to do things like this:
This is useful but we can also use this in function definitions:
1 2 3 4 5 6 7 8 9 10 11
We can rearrange or omit parameters as needed. One feature Node.js still does not have is runtime parameter validation. If all parameters are omitted, the interpreter will not complain.
An equivalent function definition in Python would look like this:
1 2 3 4
The difference between the Node.js and Python examples is that if either parameter is omitted here, an error will be raised.
If anyone has an idiomatic and DRY approach for parameter validation in Node.js, I would love to hear it.