title: Given a string describing a Javascript function, convert it to a Javascript function
body: <p>Say I've got a Javascript string like the following</p>
  
  <pre><code>var fnStr = "function(){blah1;blah2;blah3; }" ;
  </code></pre>
  
  <p>(This may be from an expression the user has typed in, duly sanitized, or it may be the result of some symbolic computation.  It really doesn't matter).</p>
  
  <p>I want to define <code>fn</code> as if the following line was in my code:</p>
  
  <pre><code>var fn = function(){blah1;blah2;blah3; } ;
  </code></pre>
  
  <p>How do I do that?</p>
  
  <p>The best I've come up with is the following:</p>
  
  <pre><code>var fn = eval("var f = function(){ return "+fnStr+";}; f() ;") ;
  </code></pre>
  
  <p>This seems to do the trick, even though it uses the dreaded <code>eval()</code>, and uses a slightly convoluted argument.  Can I do better?  I.e. either not use <code>eval()</code>, or supply it with a simpler argument?</p>