That's about it. I have a string = "sum" and a function named sum(a,b), how can I substitute my string to call that function;
string = "sum"
function sum(a,b)
So basically to call that function, I would want to execute it like
string(a, b)
That's about it. I have a string = "sum" and a function named sum(a,b), how can I substitute my string to call that function;
string = "sum"
function sum(a,b)
So basically to call that function, I would want to execute it like
string(a, b)
I suggest you use dictionary, where you define all existing functions:
const funcs = {
sum: function(a, b) {
},
someStuff: function(r, f) {
}
};
//call it:
funcs["sum"](a, b);
You can simply access your function via indexing with the strings