title: setTimeout - how to avoid using string for callback?
body: <p>When using <code>setTimeout</code>, you have to put the code you want to execute into a string:</p>
  
  <pre><code>setTimeout('alert("foobar!");', 1000);
  </code></pre>
  
  <p>However, I want to execute a function to which I have a reference in a variable. I want to be able to do this:</p>
  
  <pre><code>var myGreatFunction = function() { alert("foobar!"); };
  // ...
  setTimeout('myGreatFunction();', 1000);
  </code></pre>
  
  <p>(Though in real life, the alert is a lengthier bit of code and <code>myGreatFunction</code> gets passed around as a parameter to other functions, within which the <code>setTimeout</code> is called.)</p>
  
  <p>Of course, when the timeout triggers, <code>myGreatFunction</code> isn't a recognised function so it doesn't execute.</p>
  
  <p>I wish javascript let me do this, but it doesn't:</p>
  
  <pre><code>setTimeout(function() { myGreatFunction(); }, 1000);
  </code></pre>
  
  <p>Is there a nice way round this?</p>