ok I have this small code
http://jsfiddle.net/laupkram/yJtyD/
now its not really working. I had been following all the existing questions and answers here in SO but I can’t make this up.
I really want to call a function without using eval()
where i had been wrong?
You can’t execute a string directly. If the function specified by the string is defined globally you can access the function by
So in your case this would transform your code to the following:
If the function is defined only in another function’s scope, you have to resort to
eval, which has some performance disadvantages and is generally considered bad practice (see, e.g., MDN).PS: This won’t work in a jsFiddle as they use sandboxing, which is like defining
imafunc()inside another function. You have to change the wrapping to use “no wrap”.