Is there a way to pass an unknown number of arguments like:
var print_names = function(names) {
foreach(name in names) console.log(name); // something li
I like to do this:
This will not help if you don't know the number of arguments, but it helps if you don't want to remember the order of them.
/**
* @param params.one A test parameter
* @param params.two Another one
**/
function test(params) {
var one = params.one;
if(typeof(one) == 'undefined') {
throw new Error('params.one is undefined');
}
var two = params.two;
if(typeof(two) == 'undefined') {
throw new Error('params.two is undefined');
}
}