-1

I would like to check if function is defined or not dynamically. I have a functionName variable which can be dynamicly changed... Here is my code:

function callback_user_login(object, status) {
    handle_simple_message(object);
}

var functionName = "callback_user_login";
console.log(typeof functionName); // returns string

How can I pass dynamicly named function name to typeof?

1 Answers1

0

If its in the global scope you can check

    window[varName]

or

    globalThis[varName]
Sean Morris
  • 384
  • 2
  • 9