Problem: A Javascript function needs few parameters to work with:
function kick(person, reason, amount) {
// kick the *person* with the *amount*, based on the *reason*
}
As there's no way to do function overloading in JS like how you do in Java, if it needs to be designed for easy future improvement (parameters adding), it can be written as:
/* Function Parameters pattern */
function kick() {
// kick the person as in *arguments[0]*, with the amount as in *arguments[1]*,
// based on the reason as in *arguments[2]*, with the strength as in *arguments[3]*
}
or
/* Object Configuration Pattern */
function kick(config) {
// kick the person as in *config.person*, with the amount as in *config.amount*,
// based on the reason as in *config.reason*, with the strength as in *config.strength*
}
I do know that Object Configuration Pattern allows augmentation for any default properties.
So, the question is: If I don't need to augment any properties with the parameters, is there any significant reason of using any one of the proposed solutions as opposed to the other?