title: In JavaScript, how to execute next function from an array of functions
body: <p>I have an array of functions, as in:</p>
  
  <pre><code>funcArray = [func1, func2, func3];
  </code></pre>
  
  <p>When in a given function, I want to execute the next function in the array. How do I do this? Here is my basic skeleton:</p>
  
  <pre><code>function func1() {
    // I get current function caller
    var currentFunc = func1.caller;
  
    // I want to execute the next function. Happens to be func2 in the example.
  
  }
  </code></pre>
  
  <p>I cannot use <code>indexOf</code> function, as one would for an array of strings or numbers.
  <strong>NOTE</strong>: This question appears to be similar to <a href="https://stackoverflow.com/questions/44015982/how-to-check-the-index-of-a-function-in-an-array-of-functions-in-javascript">this</a> and the one it refers to. However, it is a different question.</p>
  
  <p>I want to alter the sequence of processing by merely modifying the array. That's the goal. A possibly more efficient approach would be appreciated.</p>
  
  <p><strong>Clarification</strong>: Based upon some of the comments:
  funcArray is global.</p>
  
  <p>The goal is to implement middleware for a Node.js HTTP module in <strong>as simple and efficient</strong> a manner as possible without using any third-party modules.</p>