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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:12:09+00:00 2026-06-06T02:12:09+00:00

I have a function in javascript: function test(){ … if (){ setTimeout(test(), 1000); }

  • 0

I have a function in javascript:

function test(){
...
    if (){
        setTimeout(test(), 1000);
    }
}

according to the manual, i can call this with:

setTimeout(test(), 1000);

in fact, it calls, but do not wait the 1s. so I try to use it like the following and it works.

setTimeout(function(){test();}, 1000);  

Anyone can explain this to me?

  • 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-06T02:12:11+00:00Added an answer on June 6, 2026 at 2:12 am

    You should be calling with

    setTimeout(test, 1000);
    

    and NOT with

    setTimeout(test(), 1000);
    

    In other words, the function you want to call after 1000 ms is test, not the result of calling test!

    The reason why

    setTimeout(function(){test();}, 1000);  
    

    works is that the function you call after 1000ms is a function that calls test, which is basically test itself. For lambda calculus geeks, that’s called eta-reduction.

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

Sidebar

Related Questions

Hi i have this javascript function function test(){ var count = 0; var date1
Sorry if this is a stupid question, I have a javascript function like: Test.prototype.createElement
I have this javascript function that block special characters... function validaTexto(texto) { !(/^[A-zÑñ0-9]*$/i).test(texto.value) ?
I have the following page: <html> <head> <title>Test</title> <script type=text/javascript> function BuildTree() { var
I have a JavaScript function (which users on this forum graciously helped me construct)
i have this javascript function: print <<"EOT"; <script type="text/javascript"> function alertSize() { var myWidth
I have this JavaScript function to create a table with image cells: function Draw(array)
I have a javascript function for shrinking images but I dont want the shrinking
So, I have this JavaScript function: ME.Utils = { RxEmail: new RegExp(/^(([\w-\s]+)|([\w-]+(?:\.[\w-]+)*)|([\w-\s]+)([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i), ValidateEmail: function(email)
I have the following code - <script type=text/javascript> function test() { var results =

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.