I currently store a function in a variable, and then call it:
var function_name = 'test_function';
// some other JS here
if (typeof app[function_name] != 'undefined') {
app[function_name];
}
app.test_function = function() {
alert('woo');
};
This works fine, but what if I store arguments in the function name variable? Like this:
var function_name = 'test_function("mike")';
// some other JS here
if (typeof app[function_name] != 'undefined') {
app[function_name];
}
app.test_function = function(name) {
alert(name);
};
This doesn't work, because typeof app[function_name]
is undefined.
How can I do this?
Aucun commentaire:
Enregistrer un commentaire