setInterval vs setTimeout

Both are Javascript’s timing events.

setInterval(function(), milliseconds):

  • Executes a function repeatedly, with a fixed time delay between each call to that function. (useful for countdown)
  • clearInterval() takes an in-scope variable which points to the setInterval method and stops the function from looping.


setTimeout(function(), milliseconds):

  • Executes a function once, after waiting a specified delay.
  • clearTimeout() stops the execution, thus disabling it from running again in the future.


  • 1000 milliseconds = 1 second
setInterval vs setTimeout

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s