How to handle an unknown number of arguments?
Hey guys, did you know that JavaScript functions can have unknown arguments? JS functions can also have optional arguments and an even optional number of arguments!
And the best part of it, is that arguments can be treated as arrays, including built-in JavaScript methods.
To explain this using a very simple example, let’s create a function, that will sum up any numbers that are passed to it.
Try it live at JSFiddle, or simply click ‘Result’ in the form below: