Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
devwiki:javascript [2024/02/03 15:17] – [UI interaction operation] ying | devwiki:javascript [2024/02/03 15:18] (current) – [Timer operation] ying | ||
---|---|---|---|
Line 82: | Line 82: | ||
====== Timer operation ====== | ====== Timer operation ====== | ||
- | * If the timer is intended to run indefinitely and you want a continuous countdown, the setInterval method is a simple and suitable choice. | + | * If the timer is intended to run indefinitely and you want a continuous countdown, the setInterval method is a simple and suitable choice. To stop, you need to explicitly clear it using clearInterval. |
* If you want more control over the execution, especially if there are additional conditions for stopping or restarting the timer, the setTimeout recursive approach might be preferred. | * If you want more control over the execution, especially if there are additional conditions for stopping or restarting the timer, the setTimeout recursive approach might be preferred. | ||