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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:30:38+00:00 2026-06-10T11:30:38+00:00

If I call clearTimeout for a setTimeout event that has already fired but whose

  • 0

If I call clearTimeout for a setTimeout event that has already fired but whose callback is still on the execution queue, will the clearTimeout still prevent that event from being processed?

In other words, is it still possible to clear a timeout event during the delay of the timer firing and its callback being executed?

Informally speaking, my guess is that once the timeout fires, it queues up the callback and destroys itself – making a clearTimeout with that timer’s id have no effect on the queued up callback.

  • 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-10T11:30:39+00:00Added an answer on June 10, 2026 at 11:30 am

    I think the answer is yes. (I’m using Firefox at the moment.)

    edit — for completeness, the test I constructed was this:

    var t1 = setTimeout(function() {
      clearTimeout(t2);
    }, 0);
    
    var t2 = setTimeout(function() {
      alert("hello world");
    }, 0);
    

    The idea is that both timers should become “ready” immediately after that script block is finished, and they should run in the order they were requested. Thus, “t1” should clear “t2” before the browser runs its callback. Because no alert() happens, I concluded that the clearTimeout() call “worked” in that it prevented the second callback from running even though it’s timer had already expired.

    Exactly how things work in the browser(s) is not something I’m familiar with, so there could be some situation where the clearTimeout() doesn’t have the same effect. It seems pretty non-deterministic anyway, given the execution model.

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

Sidebar

Related Questions

I call the following function with a mouseover event but it's not working. My
The Javascript timer event has this basic syntax: var t=setTimeout(javascript statement,milliseconds); I have this
Call me stupid but this thing has been eating away my productive time like
I have this code that make an image animation, but I want to call
I call from a spreadsheet module a function that does some processing in another
Users call a web service API in my PHP code but don't properly encode
I call an URL that returns me JSON (I use JSONKit). I convert it
I call this a flash meeting, but maybe there is another more appropriate name.
When I call set timeout it returns a number, for example > setTimeout(function(){ console.log('done');
I would like to use a setTimeout function so that Ajax calls are only

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.