Calling function from another function - Javascript API
<p>I'm new in javascript and I have a problem I can't solve.</p>

<p>In the beginning I had the following code, and worked just fine</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function foo(){
    var load_b = new Array();
    load_b = b();
}

function a() {
    var files = document.getElementById("images").files;
    return files;
}

function b(){
    var get_a = a.call(get_a);
    return get_a;
}</code></pre>
</div>
</div>
</p>

<p>Now I'm trying to create an API, and the problem is that when I do <code>var get_a = a.call(get_a);</code> or <code>var get_a = a();</code>, I get an:</p>

<blockquote>
  <p>Uncaught ReferenceError: a is not defined(…).</p>
</blockquote>

<p>I tried many different ways of calling a from b, but I always get an error. Currently my code looks like this. Do you guys have any ideas?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function foo(){
    var new_api = new my_api();
    var load_b = new Array();
    load_b = new_api.b();
}

var my_api = function(){
    return {
        a : function a() {
            var files = document.getElementById("images").files;
            return files;
        },
        b : function b() {
            var get_a = a();
            return get_a; 
        }
    }
}</code></pre>
</div>
</div>
</p>