Finding the number of function parameters in JavaScript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4848149/get-a-functions-arity">Get a function&#39;s arity</a>  </p>
</blockquote>



<p>Say I have:</p>

<pre><code>function a(x) {};
function b(x,y) {};
</code></pre>

<p>I want to write a function called numberOfParameters that returns the number of parameters that a function normally accepts. So...</p>

<pre><code>numberOfParameters(a) // returns 1
numberOfParameters(b) // returns 2
</code></pre>
