setTimeout/setInterval experiment involving slow-downs
✓ Published0🌍 Public
HHerst
Last edited Aug 13, 2017
Created on Aug 13, 2017
This example demonstrates how `setTimeout` and `setInterval` differ in their behavior when a callback runs longer than the specified interval. It shows that `setInterval` can queue overlapping calls, while `setTimeout` waits for the previous execution to finish. The visualization uses a counter and a select menu to switch between the two methods, with a checkbox to artificially slow down the `tick` function via a blocking `while` loop. The code relies on D3.js v4 for DOM selection and event handling, and uses `window.setTimeout` and `window.setInterval` to schedule the counter updates. The counter increments by 0.5 every 500 milliseconds.
AI-generated descriptionsetTimeout vs. setInterval experiment involving slow-downs.
gpl-3.0 Licensed