+ 7
Long List Of Function Parameters To Pass Vs Using Objects Which One Is Better
3 Antworten
+ 4
I will go for rest operator to gather all passed arguments into a giant array.
e.g
function someFunc(...args) {
// args is array ready to use
}
Object will work too, but you need to specifically create the object and pass to the function.
Hope it helps.... happy coding!
+ 5
Terminator and Ben Bright, that is a good point after all to avoid long parameter lists in functions and to save on typing and make code more readable - it is better to go with objects and use a dot seperator to access properties rather than pass a long list of arguments as parameters to a function.
With limited knowledge in C I wrote a program using lists of parameters passed to functions - it works but in retrospect I should have studied typedef, structures and pointers to efficiently use the dot seperator to access members.
https://code.sololearn.com/caDwB0xF4Kqx/?ref=app
+ 2
Use Object