Forum Discussion
Hi,
Still not sure about actual problem and use case that caused it. Can you describe it with more details?
The simple and obvious solution is to create a third function that will call required two ones and call this function. Technically it will be one-liner.
But something tells me that this is not what you are looking for.
(If you are looking for concurrent code execution (like calling different functions from two different threads), then this is not possible in scripting languages.)
Got the solution from Smartbear.
In JavaScript, store your functions in the arrays and call them using key values. Here is the example code:
function f(){
let dyn_functions = [];
dyn_functions['Test1'] = function (arg1, arg2) {
return arg1 - arg2
};
dyn_functions['Test2'] = function (arg1, arg2) {
return arg1 + arg2
};
// calling one of the functions
let result = dyn_functions['Test1'](1, 2);
// this works as well
let result2 = dyn_functions.Test2(1, 2);
Log.Message("")
}
Thanks everyone for looking into the issue.
- AlexKaras6 years agoChampion Level 3
Still did not get use case and thus the actual need and the principal difference of the suggested solution from just calling two functions from the third one (the wrapper)...
But the above is irrelevant as long as you are satisfied with the suggested approach.
Related Content
Recent Discussions
- 2 hours agongerwe
- 18 hours agosimonaferrara
- 22 hours agomacheshmeh