title: Call jQuery defined function via string
body: <p>I'd like to call functions I've defined within the document ready function of jQuery, but am having a bit of trouble. I have the following code:</p>
  
  <pre><code>jQuery(document).ready( function($) {
  
      function test1() {
          alert('test1');
      }
  
      function test2() {
          alert('test2');
      }
  
      var test_call = '2';
  
      var fn = 'test' + test_call;
  
      // use fn to call test2
  
  });
  </code></pre>
  
  <p>I don't want to use <code>eval</code>, and <code>window[fn]</code> doesn't seem to be working. The two test functions don't appear to be indices in the window variable. I appreciate the help and knowledge.</p>