Long List Of Function Parameters To Pass Vs Using Objects Which One Is Better | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Long List Of Function Parameters To Pass Vs Using Objects Which One Is Better

10th Mar 2019, 8:27 AM
Kailash Loncha
Kailash Loncha - avatar
3 Answers
+ 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!
10th Mar 2019, 11:25 PM
Benneth Yankey
Benneth Yankey - avatar
+ 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
10th Mar 2019, 11:40 AM
boneSpider
boneSpider - avatar
+ 2
Use Object
15th Mar 2019, 9:34 PM
Ismail Abdulqudus Alashe
Ismail Abdulqudus Alashe - avatar