var timeoutID;function delayedAlert() { timeoutID = window.setTimeout(slowAlert, 2000);}function slowAlert() { alert('That was really slow!');}function clearAlert() { window.clearTimeout(timeoutID);}