I have this function call passed as a string:
var dcall = "tumbsNav(1)";
Is it possible to execute this dynamically like exec in SQL??
exec(dcall)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Wherever you’re storing
You can instead store
Wherever you were calling it, instead of calling
You can instead call
The only case this wouldn’t work is iftumbsNavwasn’t defined at the timevar func = ...is called. Then you would have to store the string. If the string is completely under your control, then there’s no security hole, but be aware of all the problems mentioned by @PorcoAs Kolink mentioned, my example would not cause a problem if
tumbsNavwas not defined when assigning it with a wrapped anonymous function that calls tumbs. The comment above would only make sense if the example had been the following: