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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:49:59+00:00 2026-06-14T23:49:59+00:00

Is it possible to re-run the function ‘check’ without calling check() in the else

  • 0

Is it possible to re-run the function ‘check’ without calling check() in the else statement? Maybe call itself somehow?

If I have multiple instances of this function, they end up calling each other, unless I change it to check1, check2, etc.. While this is prob. a performance killer, I was just trying it out for a prototype app.

(function check () {
  if (typeof foo !='undefined') {
    // do stuff
  } else {
    console.log("Failed to load, trying again");
    setTimeout(function(){ check(); }, 10);
  }
})();
  • 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-14T23:50:00+00:00Added an answer on June 14, 2026 at 11:50 pm

    Well, you could use arguments.callee to call it, but it’s a bad idea, a performance hit, and it isn’t valid in strict mode.

    What you’ve quoted is valid JavaScript and should not make check call another check function if you have one alongside it. Sadly, though, it will in IE8 and earlier because they quite incorrectly leak the name check to the surrounding scope (named function expressions do not add the function name to the surrounding scope like function declarations do — except on IE8 and earlier [and that’s not all they get wrong with them]).

    So the solution is to use an anonymous function to hide a named one:

    (function() {
        // A check function
        check();
        function check () {
          if (typeof foo !='undefined') {
            // do stuff
          } else {
            console.log("Failed to load, trying again");
            setTimeout(function(){ check(); }, 10);
          }
        }
    })();
    (function() {
        // A complete different one
        check();
        function check () {
          if (typeof foo !='undefined') {
            // do other stuff
          } else {
            console.log("Failed to load, trying again");
            setTimeout(function(){ check(); }, 10);
          }
        }
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is possible to run the urlencode function without converting # or % ?
I'm not sure if its possible, but I'd like to have a function run
Possible Duplicate: Run javascript function when user finishes typing instead of on key up?
is it possible to run a sub or function as soon as the user
Is it possible to run a query using ILIKE with the IN function? For
Is it possible to run package.skeleton('pkgname') and have all of the .R files end
I need to run a function that takes two arguments several times. I have
Is it possible to run a function when the session ends on a PHP
Possible Duplicate: Run a simple shell command Is there a Win32 API function that
I would like to have a VBA function run as soon as Outlook starts

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.