1var myVar;
2
3function myFunction() {
4 myVar = setTimeout(function(){ alert("Hello"); }, 3000);
5}
6
7function myStopFunction() {
8 clearTimeout(myVar);
9}
1var timer1 = setTimeout(function() { removeStatusIndicator(); }, statusTimeout);
2
3clearTimeout(timer1)
1// wait 1000ms and then run func()
2let myTimeout = setTimeout(func, 1000);
3// cancel the timeout
4clearTimeout(myTimeout);