Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:59:23+00:00 2026-06-13T02:59:23+00:00

setTimeout and setInterval What is the difference between, for example, in the long-running function

  • 0

setTimeout and setInterval What is the difference between, for example, in the long-running function when the UI process?

  setTimeout(function(){
    /* Some long block of code... */
  }, 10);

  setInterval(function(){
    /* Some long block of code... */
  }, 10);

If there is a long execution time, the execution time is greater than setTimeout or setInterval to set the time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:59:24+00:00Added an answer on June 13, 2026 at 2:59 am

    setTimeout runs once and is good to use when you either

    1. only want to run once
    2. or runtime per call is variable and you
      need to have the call made sequentially

    setInterval runs forever until you call clearInterval to cancel.

    So, for long running process, it’s good to use setTimeout and then have your setTimeout handler call setTimeout again to keep the loop running.

    EDIT
    The problem w/ setInterval is that if it takes longer than 10ms (in your case) to run then that next call can be dropped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the main difference between setInterval and setTimeout in JavaScript?
I want to know the difference between setInterval() (or) setTimeout() in DOM and polling
Is there any difference between these 2 statements setInterval(animateImage, 1000); or setInterval('animateImage()', 1000); Will
So I know that there are differences between setTimeout and setInterval , but consider
how can i implement setInterval or setTimeout on click of button. my code bellow
Does setTimeout work from WITHIN setInterval ? I'm writing some JavaScript to animate some
There's example: http://www.jquery4u.com/jquery-functions/setinterval-example/#.UHW6_IYY18E Hover over RSS feedburner image - it will shake. In my
I have multiple instances of the following code. var start_time = new Date().getTime(); setTimeout(function
The window.setTimeout (and related setInterval) function in Javascript allows you to schedule a function
For example, there is for loop that I want to sleep for some seconds.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.