title: Determine a function object's parameter types
body: <p>I'm trying to find a way to determine a function objects parameters so that I can determine their respective types.</p>
  
  <pre><code>Params.prototype.getParams = function (fn) {
     var a = fn.length;
     console.log("Args: " + a);
  
     for (var i = 0; i &lt; a; i++) {
        // This is where I want to print the type
        console.log("Arg[" + i + "] type is: " + typeof(fn.arguments[i]));
     }
  }
  </code></pre>
  
  <p>Then if I define a few functions (could be any JS functions), such as:</p>
  
  <pre><code>function callback1("one") {}
  function callback2("one", 2) {}
  function callback3(1, "two", []) {}
  </code></pre>
  
  <p>If I later invoke each:</p>
  
  <pre><code>var params = new Params();
  
  params.getParams(callback1);
  params.getParams(callback2);
  params.getParams(callback3);
  </code></pre>
  
  <p>I would like to figure out each param type for each function instance.  I've Google'd it, searched it on SO but can't find anything helpful.  If it knows the 'length' I don't see why it wouldn't know the params also?</p>
  
  <p><strong>Update - 2013.02.19 17:41</strong></p>
  
  <p>Yes, I do know there are potential errors in the code above, I stripped it for simplicity of reading.</p>
  
  <p>Here is what I was trying to accomplish:</p>
  
  <p>I was reading this (interesting) article:  <a href="http://ejohn.org/blog/javascript-method-overloading/" rel="nofollow">JavaScript Function Overloading</a></p>
  
  <p>Coming from Java and being a purist, I wanted to start experiment with method overloading (damn I can't believe how primitive JS is).  </p>
  
  <p>I wanted to 'enhance' the example in the article by replacing the 'function count' methodology with one where the parameter types are used instead to 'resolve' which overloaded function should be invoked.  It seems this is pretty much only doable by actually knowing the parameter types of 'fn' in my example.</p>