What is diffrent's between setTimeout & setInterval ? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

What is diffrent's between setTimeout & setInterval ?

What is diffrent's between setTimeout & setInterval ?

28th Dec 2018, 7:02 PM
Tuhidul islam Mridul
Tuhidul islam Mridul - avatar
2 Réponses
+ 3
In simple term, setTimeout() will execute script only once after x milliseconds. eg)setTimeout(function(){ alert("Hello"); }, 3000);//after 3 sec setInterval() will execute script after every x milliseconds eg)setInterval(function(){ alert("Hello"); }, 3000);//after every 3 sec
28th Dec 2018, 8:40 PM
Rishi Anand
Rishi Anand - avatar
+ 1
setTimeout - calls a function once, setInterval - calls a function many times
28th Dec 2018, 7:49 PM
Игорь Яковенко
Игорь Яковенко - avatar