+ 1

How to pass an unknown numner of arguments in a javascript function?

I tried browsing and found that we can do this by: function func(...x) { } But it doesn't seem to work !

28th Jan 2019, 6:40 PM
Shubham Tiwary
Shubham Tiwary - avatar
3 odpowiedzi
28th Jan 2019, 8:04 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Try making the argument an array, then loop through each key of the array in your function, stopping at array.length.
28th Jan 2019, 10:41 PM
James
James - avatar
28th Jan 2019, 10:48 PM
James
James - avatar