How do I pass a function as a parameter without the function executing in the \"parent\" function or using eval()? (Since I\'ve read that it\'s insecure.)
eval()
Example 1:
funct("z", function (x) { return x; }); function funct(a, foo){ foo(a) // this will return a }
Example 2:
function foodemo(value){ return 'hello '+value; } function funct(a, foo){ alert(foo(a)); } //call funct funct('world!',foodemo); //=> 'hello world!'
look at this