Like C# params, JavaScript also supports variadic functions. In variadic functions the total number of parameters are unknown and can be adjusted at the time of calling the function.
In computer programming, a variadic function is a function of variable arity; that is, one which can take different numbers of arguments. Support for variadic functions differs widely among programming languages.
In the javascript the parameters can be directly accessed into the function from the "arguments".
Take below example
function PrintList() { for (var i = 0; i < arguments.length; i++) { document.write(arguments[i] + "<br />"); } } // Call to Variadic Function PrintList('Google', 'Microsoft', 'Yahoo', 'Adobe');
3 comment(S)