javascript reset timeout code example
Example 1: how to reset settimeout in javascript
// Get a reference to the timeout and call wwindow.clearTimeout() on
// that refrence.
let timeoutHandle = window.setTimeout(...);
window.clearTimeout(timeoutHandle);
Example 2: clear timeout in function js
var timer;
function endAndStartTimer() {
window.clearTimeout(timer);
var millisecBeforeRedirect = 10000;
timer = window.setTimeout(function() {
alert('Hello!');
}, millisecBeforeRedirect);
}