Javascript clearInterval()

Description

Javascript clearInterval()


// Create an alert that will appear after 10 seconds
let myTimerObj = setTimeout(function(){ console.log('Hello!'); }, 10000);

// Cancel the timer
clearTimeout(myTimerObj);//from ww  w.  ja va  2s . c o  m

// have an alert box appear every 10 seconds
let myIntervalObj = setInterval(function(){ console.log('Hello!'); }, 10000);

// cancel it
clearInterval(myIntervalObj);



PreviousNext

Related