i need to replace method apply to call or the other.
this[aType].apply(this, aParams)
of course, aParams must be an array.
how can i do it?
i'm waiting your opinion
i need to replace method apply to call or the other.
this[aType].apply(this, aParams)
of course, aParams must be an array.
how can i do it?
i'm waiting your opinion
I cant really connect to why you exactly need it, as pointed by other users here. But in case you need it, I would say it`s an interesting problem to solve. And you might be definitely interested in the powers of Spread and rest operators in ES6 module.
Check how you can send an array of parameters using the call function here:
function abc(x, y) {
console.log(x, y);
}
var a = [1, 4];
abc.call(this, ...a)
For .apply should use arguments as array, But in .call using arguments as parameter.
var aParams = ['aParam1','aParam2'];
this[aType].apply(this, aParams);
this[aType].call(this,aParams[0],aParams[1]);
if its n
number
for (var i = 0; i < aParams .length; i++) {
(function(i) {
}).call(this , aParams[i]);
}
Pass the arguments to the call function
this[aType].call(this, aParams[0],aParams[1],aParams[2])