Call a function whose name is defined in a string - Javascript Function

Javascript examples for Function:Function Variable

Description

Call a function whose name is defined in a string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w  w  w.  j  a v a 2 s  .  c  o m
function A() { console.log("A") }
function B() { console.log("B") }

function C(parm) {
  parm();
}
C(A)
C(B)
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials