'Dynamically call JavaScript function with multiple arguments [closed]
How can I call this function dynamically? How can I pass arguments dynamically inside braces of this dynamic call?
function a(b,c,d){
}
var functionName = 'a';
window [functionName]();
Solution 1:[1]
Well, it's much more simplier then you think
var f = function (a, b, c) {...};
var a = ...,
b = ...,
c = ...;
//to call a function do
f(a,b,c);
//or
f.call(null, a, b, c);
//or
f.apply(null, [a,b,c]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eugeny89 |
