You can't execute a string directly. If the function specified by the string is defined globally you can access the function by
window[ fn ]();
So in your case this would transform your code to the following:
var fn = "imafunc";
if (typeof window[ fn ] === 'function') {
window[ fn ]("hello world");
}
function imafunc(str) {
alert(str);
}
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".