I've really fallen in love with object destructuring with functions.
For example:
var buyCoffee = function({sku, pounds = 1, roast:''}){
...more code
}
buyCoffee({sku:"cf-100" pounds: 3, roast: 'dark'});
buyCoffee({sku:"cf-101" roast: 'light'});
Pros
- Flexibility similar to the args object.
- Added Simplicity
- Not required to put in parameters if I don't need them.
Cons
- Variable names are locked all the way through.
- Currying would be much harder.(From what I can tell)
- Significant computational overhead vs traditional params ?
- Harder to test?
I'd like to know what downsides there are to this approach? Is this a good pattern to use as I grow as a developer? Just looking for some wisdom from the trenches on this. Thoughts?