JSFiddle wraps your JavaScript inside a function so myFn
is in the local scope of another function.
Use:
window.myFn = function () {
console.log("called");
}
var callbackName = "myFn";
console.log(window[callbackName]());
This way you explicitly define global function called myFn
.
Another option (as @Barmar said) is to use the JSFiddle's option "No wrap".