Is it possible to have a static function that calls a dynamically defined function? I need this because I can't change the static function, and all I know is that it calls the dynamic function. For example:
function staticFunc() {
dynamicFunc();
}
function test() {
function dynamicFunc() {console.log('yay');}
staticFunc();
};
test();
but it gives me the error dynamicFunc is not defined.
I know that if I hardcode staticFunc in test(), it works. I also noticed that I only get the error when I call staticFunc, not when I define it (even though dynamicFunc is not defined yet), which makes it seem like staticFunc is running inside test()'s scope, but evidently not.
Any way to do this? The only way I can think of is to make a global function funcPtr that gets assigned to my dynamic function.