title: JavaScript: Passing different count of parameters to callback function
body: <p>Every time I want a function run with callback, I have to change my parameter from <code>(par1,par2)</code> to <code>(args)</code>. Is there any way to keep my parameter name?</p>
  <p>Here is my code now:</p>
  <pre><code>function runwithcallback(callback, ...args) {
    callback(args);
  }
  
  function Boo(args){
    let par1 = args[0];
    let par2 = args[1];
  }
  function Foo(args){
    let par1 = args[0];
    let par2 = args[1];
    let par3 = args[2];
  }
  
  //normal call
  Boo([&quot;1&quot;,&quot;2&quot;]);
  Foo([&quot;1&quot;,&quot;2&quot;,&quot;3&quot;]);
  
  //call with callback
  runwithcallback(Boo,&quot;1&quot;,&quot;2&quot;);
  runwithcallback(Foo,&quot;1&quot;,&quot;2&quot;,&quot;3&quot;);
  </code></pre>
  <p>And what I want:</p>
  <pre><code>function runwithcallback(callback, ...args) {  
    callback(args);
  }
  
  function Boo(par1, par2){
  } 
  function Foo(par1, par2, par3){ 
  }
  
  //normal call
  Boo(&quot;1&quot;,&quot;2&quot;);
  Foo(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;);
  
  //call with callback
  runwithcallback(Boo,&quot;1&quot;,&quot;2&quot;); 
  runwithcallback(Foo,&quot;1&quot;,&quot;2&quot;,&quot;3&quot;);
  </code></pre>