title: Sequence of setTimeout in JavaScript
body: <p>Can someone explain me, why if I create a function in JavaScript and add it to <code>setTimeout</code>, <code>setTimeout</code> doesn't work properly, but if I create anonymous function everything is okay? Example below:</p>
  
  <p><strong>It works:</strong></p>
  
  <pre><code>setTimeout(function() {
      alert("foo");
  }, 100);
  </code></pre>
  
  <p><strong>It doesn't works:</strong></p>
  
  <pre><code>function foo() {
      alert('foo');
  }
  setTimeout(foo, 100);
  </code></pre>