Call javascript function which name is in variable

This question already has an answer here:

  • How to execute a JavaScript function when I have its name as a string 29 answers

  • window[name]()
    

    您可以通过名称引用来调用函数,方法是将它们选作window的属性并执行它们


    have you tried variableName(); ?

    We often pass around callback functions, which might look something like this

    function doSomething(callbackFunction){
        // some happy code
        callbackFunction()
    }
    
    链接地址: http://www.djcxy.com/p/94824.html

    上一篇: 调用名称存储在变量中的函数

    下一篇: 调用JavaScript函数名称在变量中