I searched around and didn't really find a question regarding this.
So I have a function which can take multiple parameters ,(the number of parameters doesn't matter) something like this:
function print(){
for(var i = 0; i<arguments.length; i++ ){
console.log(arguments[i]);
}
}
and I have all the parameters in an array, like:
var params = [param1,param2,...];
I need to call the function with those parameters stored in the params array. Well, I could do this if I knew the number of params:
print(params[0],params[1],...);
but I don't know the number of params and need a way to call the function with all of them.
Is there anyway I can do this? I tried using print.call(params), but the call method doesn't work that way.
thanks