title: Create a function at runtime
body: <p>Is there a way to create a function at runtime with content that is unknown (but trusted) at design-time WITHOUT using eval()?</p>
  
  <p>Basically I am trying to create a "hard coded" function for performance reasons as it is going to be called many, many times.
  Only the "hard coding" will be done once at runtime just before the many calls begin.</p>
  
  <p>(untested example)</p>
  
  <pre><code>var strFuncString = 'function(){';
  for (some loop)
  {
      strFuncString+='DoSomething()'; //if this can be made to reference an object obtained for the for-loop then even better - i.e. Myfunc+=Obj.DoSomething
  }
  var MyFunc = eval(strFuncString  '}');
  
  SomeProcessThatCallsItsArgALot(MyFunc);
  </code></pre>
  
  <p>I tried this in the debugger but unsurprisingly it didn't work</p>
  
  <pre><code>((function(){console.log(1);} )+( function(){console.log(2);}))()
  </code></pre>