How to execute a JavaScript function when I have its name as a string ?
Don't use eval unless we absolutely, positively have no other choice.
As has been mentioned, using something like this would be the best way to do it:
That, however, will not work with a namespace'd function:
This is how we would do that:
In order to make that easier and provide some flexibility, here is a convenience function:
we would call it like so:
can say
or as many others have suggested, you can just use eval:
do this:
Then we can call: