How does Javascript timing really work?
<p>Say I have some code:</p>

<blockquote>
<pre><code>setInterval(foo,1000); // here is an interval that causes a function to repeat
</code></pre>
</blockquote>

<pre><code>function foo(){
//a number of lines of code
}
</code></pre>

<p>Now, i think of this as causing <code>foo()</code> to be executed every second by the system clock, whereas this:</p>

<blockquote>
<pre><code>function foo(){
//a number of lines of code
setTimeout(foo,1000);    } //here is a timeout that causes the function to repeat
</code></pre>
</blockquote>

<p>Am I correct in guessing that the latter function would be executed less often in a given period of time, because I'm inserting a pause <em>between</em> executions (which, themselves, take a measurable amount of time)? Any further points or enlightenment on this mechanism would be welcomed.</p>
