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 6209807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:03:04+00:00 2026-05-24T06:03:04+00:00

base ={time:0}; var loop = 0; setInterval(function(){ if(base.time === 9000){ move(); base.time = 0;

  • 0
base ={time:0};    
var loop = 0;
 setInterval(function(){
    if(base.time === 9000){
        move();
       base.time = 0;
     }

  base.time ++;                      

},1);

Shouldn’t the move(); function occur every 9s? I timed it and its much less, why is that?

  • 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-05-24T06:03:04+00:00Added an answer on May 24, 2026 at 6:03 am

    setInterval will not run every millisecond. There is a minimum possible interval that is longer than that.

    If you want something to run in nine seconds, you should use setTimeout() for 9 seconds. Plus your code doesn’t reset base.time back to zero so it would only match 9000 once anyway.

    If you want it to run every 9 seconds, then you can use setInterval(handler, 9000) or you can use setTimeout(handler, 9000) and then set the next setTimeout in your handler function.

    This will execute move() every nine seconds:

    var intervalTimer = setInterval(function(){
        move();
    }, 9000);
    

    Here’s a useful article on the topic: http://www.adequatelygood.com/2010/2/Minimum-Timer-Intervals-in-JavaScript.

    To reset the time back to 9 seconds when a button is clicked use this code:

    var intervalTimer;
    
    function startTimer() {
        intervalTimer = setInterval(function(){
            move();
        }, 9000);
    }
    
    function handleClick() {
        clearInterval(intervalTimer);   // stop currently running interval
        startTimer();
    }
    
    startTimer();
    

    See it in action here: http://jsfiddle.net/jfriend00/sF2by/.

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

Sidebar

Related Questions

I have a source base that, depending on defined flags at build time, creates
I have an nHibernate Base class and have the function to return the session
I learned of the function set_include_path(). All this time, I defined a constant in
Every controller class in my project derive from a base controller class, aptly named
I use the following function for creating new objects. function newObj(o) { var params
I have a holder movieclip, its base class is foo. package { import flash.display.MovieClip;
I've just tried some simple code from example: $(document).ready(function() { var map = OpenLayers.Map('map-content',
Our base Masterpage has something like the following <head runat=server> <title></title> <script type=text/javascript src=<%=
Fragile base class is one of the most common point that gets popped up
My base class has properties that are used by a subclass. where should Release

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.