Call a function with variable number of parameters
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6770339/pass-arbitrary-number-of-parameters-into-javascript-function">Pass arbitrary number of parameters into Javascript function</a>  </p>
</blockquote>



<p>How can the following be achieved with n arguments?</p>

<pre><code>function aFunction() {

    if ( arguments.length == 1 ) {
        anotherFunction( arguments[0] );
    } else if ( arguments.length == 2 ) {
        anotherFunction( arguments[0], arguments[1] );
    } else if ( arguments.length == 3 ) {
        anotherFunction( arguments[0], arguments[1], arguments[2] );
    }

}

function anotherFunction() {
    // got the correct number of arguments
}
</code></pre>
