<script type="text/javascript"> var a = "foo"; function foo() { alert("test") } b = window[a]; typeof(b) == "function" && b(); </script>