I've seen this topic discussed in pure JavaScript using multiple techniques, but is it possible to do in Node without using window or eval()? The first technique linked uses window, which I would be more than happy to use, but when I use window[someString](); to try to call the function named in someString, I am receiving ReferenceError: window is not defined. This seems intuitive, since there's no actual window to interact with. I am looking for a functional equivalent or approximation to the following which doesn't use eval (for obvious reasons):
function myFunc(args) {
//do some code
}
var myString = 'myFunc';
eval(myString)(args);
I don't think it will be relevant, but just to cover my bases: this is for a Discord chat bot that will receive input such as !help something and then call a function which will explain what the something command does. I could switch (something) but that feels like a brute-force solution and I imagine there must be a more elegant technique.