I create functions in Javascript dynamically. Sometimes I need to check if a certain function is actually already created.
I have the name of the function a
We're adding our 2 cents because the accepted answer is right, but benefits from a little clarification:
window["myFunctionNameHere"]
is one simple way to solve the problem, but basically considering window
as any global object accessible in the desired scope.
Additionally, you must be sure to actually ASSIGN the function properly in such scope, of course.
In the case of window, for example, you'll first need
After this, the
typeof window["myFunctionNameHere"] === "function"
Will work as expected.