Call a function within a jQuery plugin using variable name
<p>I have the below code.</p>

<pre><code>(function($) {

    var myFunction = function(element) {

        var myCallerFunction = function() {
            var functionName = 'myInternalCallFunction';
            myFunction[functionName]();
            console.log(2);

        }

        var myInternalCallFunction = function() {

            console.log(1);
        }

        myCallerFunction();

    }

    $.fn.myfunction = function(options) {
        var func = new myFunction();
    }

})(jQuery);
</code></pre>

<p>Inside myCallerFunction I created a variable which holds the function name I want to call. I then try to call it, however it returns that it can't find the function. It finds the namespace myFunction okay as if I change:</p>

<pre><code>myFunction[functionName]();
</code></pre>

<p>to</p>

<pre><code>myFunctionTest[functionName]();
</code></pre>

<p>It returns it can't find "myFunctionTest" instead of not being able to find "myInterncalCallFunction".</p>

<p>Any ideas why it can't find the function?</p>
