I have registered some javascript functions in the global scope:
function Test1() {}
function Test2() {}
Now I want to run all javascript functions whose name starts with 'Test', how to do it?
I want to prevent saving each functions into a variable because it does not scale. Nor to push them to a queue and execute them later, since people need to remember adding their functions to the queue when they write the test and I don't want that.
var globalKeys = Object.keys(window);
for(var i = 0; i < globalKeys.length; i++){
var globalKey = globalKeys[i];
if(globalKey.includes("Test") && typeof window[globalKey] == "function"){
window[globalKey]();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With