143 of 264 menu

clearInterval function

The clearInterval function stops the timer set by the setInterval function. The function takes the id of the timer to stop. The timer ID is returned by the setInterval function.

Syntax

clearInterval(identifier);

Example

Let's start a timer that outputs integers every second, and then stop it when the counter reaches the value 10:

let i = 0; let id = setInterval(function() { i++; if (i == 10) { clearInterval(id); } else { console.log(i); } }, 1000);

See also

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline