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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:58:09+00:00 2026-06-15T13:58:09+00:00

I want to run my function at the first time immediately (without timeout) so

  • 0

I want to run my function at the first time immediately (without timeout) so I do this:

setInterval(function(){
    alert("Boo");
}(), 1000);

The function executed at first time but in next intervals, nothing happened. Why?

  • 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-15T13:58:11+00:00Added an answer on June 15, 2026 at 1:58 pm

    The better question is, what are you actually trying to achieve ?

    You don’t return anything from the self-invoking function, so it will return the undefined value implicitly, which is passed over to setTimeout. After the initial call, the line would look like

    setInterval(undefined, 1000); 
    

    which obviously, makes no sense and won’t continue calling anything.

    You either need to to return another function from your self-invoking function, or just don’t use a self-invoking function and just pass over the function reference.


    Update:

    You updated your question. If you want to run a function “once” on init and after that use it for the interval, you could do something like

    setInterval((function() {
        function loop() {
            alert('Boo');
        };
    
        loop();
        return loop;
    }()), 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run this PHP function -- $querystring_arr='maxResults=50&startIndex=50&sort=date'; $str=preg_replace((&startIndex=)?[0-9]*(&)?,&startIndex=.$sindex.&,$querystring_arr); When I print $str
I want to run a simple JavaScript function on a click without any redirection.
I have just started to create a stored function this is my first time
I have two jQuery functions. The first one below I want to run first,
I want to run function inside web service (.asmx file) $.ajax({ type: POST, contentType:
Want to run javascript function from parent window in child window Example I have
I want to run a function when a checkbox is checked or unchecked. However,
I want to run a function in TruClient (Firefox) every 0.1 seconds using window.setTimeout:
I want to run a function (to render flash messages) after a backbone.navigate call.
I have a C# application, and I want to run a function which is

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.