An example test visually demonstrating the difference between Underscore.js's throttle() and debounce(), the latter with the "immediate" parameter set true.
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<p>Click the meters repeatedly. Events throttled/filtered by 1 second.</p>
<ul class="meter meter1">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
<ul class="meter meter2">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
<p>
<code>_.throttle()</code> will fire once, and subsequent clicks will fire
only after 1 second has passed—but the subsequent click will happen.
<b>This is not good for filtering double-clicks.</b>
</p>
<p>
<code>_.debounce()</code> (with a <code>true</code> third parameter)
will <i>filter</i> subsequent clicks.
<b>This <i>is</i> good for filtering accidental clicks.</b>
</p>