Pass unknown number of parameters to JS function [duplicate]

What you want is probably Function.prototype.apply().

Usage:

var params = [param1, param2, param3];
functiona.apply(this, params);

As others noted, functiona declaration may use arguments, e.g.:

function functiona()
{
    var param1 = this.arguments[0];
    var param2 = this.arguments[1];
}

But it can use any number of normal parameters as well:

function foo(x, y)
{
    console.log(x);
}
foo.apply(this, [10, 0, null]); // outputs 10

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)