title: new Function() with variable parameters
body: <p>I need to create a function with variable number of parameters using <code>new Function()</code> constructor. Something like this:</p>
  
  <pre><code>args = ['a', 'b'];
  body = 'return(a + b);';
  
  myFunc = new Function(args, body);
  </code></pre>
  
  <p>Is it possible to do it without <code>eval()</code>?</p>
  
  <hr>
  
  <p>Thank you very much, guys! Actually, a+b was not my primary concern. I'm working on a code which would process and expand templates and I needed to pass unknown (and variable) number of arguments into the function so that they would be introduced as local variables. </p>
  
  <p>For example, if a template contains: </p>
  
  <pre><code>&lt;span&gt; =a &lt;/span&gt; 
  </code></pre>
  
  <p>I need to output the value of parameter <code>a</code>. That is, if user declared expanding function as </p>
  
  <pre><code>var expand = tplCompile('template', a, b, c) 
  </code></pre>
  
  <p>and then calls </p>
  
  <pre><code>expand(4, 2, 1) 
  </code></pre>
  
  <p>I need to substitute <code>=a</code> with <code>4</code>. And yes, I'm well aware than Function is similar to <code>eval()</code> and runs very slow but I don't have any other choice.</p>