please help
I have a simple example here
<script type="text/javascript" language="javascript">
function test(callback1) {
callback1();
}
var f1 = function () {
alert(1);
}
</script>
Currently, parameter of the test function is a function, when abc button is clicked, test function will be called and then test will call f1. Everything okie with me.
However, I’d like a small change like this: parameter of the test function will be a string, I mean it should be a function name, test(‘f1’) instead of test(f1).
Is it possible?How can I implement this?
Thanks
window[callback1]();Depending on use I would prefer prepare separate functions map.
It definitely doesn’t bloat
windownamespace and is more secure (window has more methods provided by browser).Don’t use eval – it’s evil!