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.)
There is a phrase amongst JavaScript programmers: "Eval is Evil" so try to avoid it at all costs!
In addition to Steve Fenton's answer, you can also pass functions directly.
function addContact(entity, refreshFn) {
refreshFn();
}
function callAddContact() {
addContact("entity", function() { DoThis(); });
}