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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:13:13+00:00 2026-05-17T00:13:13+00:00

I have recently started to tinker with Project Euler problems and I try to

  • 0

I have recently started to tinker with Project Euler problems and I try to solve them in Javascript. Doing this I tend to produce many endless loops, and now I’m wondering if there is any better way to terminate the script than killing the tab in Firefox or Chrome?

Also, is firebug still considered the “best” debugger (myself I can’t see much difference between firebug and web dev tool in safari/chrome ).

Any how have a nice Sunday!

  • 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-17T00:13:14+00:00Added an answer on May 17, 2026 at 12:13 am

    If you don’t want to put in code to explicitly exit, try using a conditional breakpoint. If you open Firebug’s script console and right-click in the gutter next to the code, it will insert a breakpoint and offer you an option to trigger the breakpoint meets some condition. For example, if your code were this:

    var intMaxIterations = 10000;
    var go = function() {
        while(intMaxInterations > 0) {
            /*DO SOMETHING*/
            intMaxIterations--;
        }
    };
    

    … you could either wait for all 10,000 iterations of the loop to finish, or you could put a conditional breakpoint somewhere inside the loop and specify the condition intMaxIterations < 9000. This will allow the code inside the loop to run 1000 times (well, actually 1001 times). At that point, if you wish, you can refresh the page.

    But once the script goes into an endless loop (either by mistake or design), there’s not a lot you can do that I know of to stop it from continuing if you haven’t prepared for this. That’s usually why when I’m doing anything heavily recursive, I’ll place a limit to the number of times a specific block of code can be run. There are lots of ways to do this. If you consider the behaviour to be an actual error, consider throwing it. E.g.

    var intMaxIterations = 10000;
    var go = function() {
        while(true) {
            /*DO SOMETHING*/
            intMaxIterations--;
    
            if (intMaxIterations < 0) {
                throw "Too many iterations. Halting";
            }
        }
    };
    

    Edit:
    It just occurred to me that because you are the only person using this script, web workers are the ideal solution.

    The basic problem you’re seeing is that when JS goes into an endless loop, it blocks the browser, leaving it unresponsive to any events that you would normally use to stop the execution. Web workers are still just as fast, but they leave your browser unburdened and events fire normally. The idea is that you pass off your high-demand tasks (in this case, your Euler problem algorithm) to a web worker JS file, which executes in its own thread and consumes CPU resources only when they are not needed by the main browser. The net result is that your CPU still spikes like it does now, but your browser stays fast and responsive.

    It is a bit of a pest setting up a web worker the first time, but in this case you only have to do it once. If your algorithm never returns, just hit a button and kill the worker thread. See Using Web Workers on MDC for more info.

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

Sidebar

Related Questions

I have recently started messing round with CodeIgniter and ran into problems when doing
I have recently started using PlayN for a hobby project and has now stumbled
We have recently started to see this exception while running the play framework in
I have recently started a new C++ project and I intend to make it
I have recently started using a shared-host for my clients so see project progress
I have recently started on a PoC project wherein we are developing a small
I have recently started doing some ActionScript/Flex programming and I am... Surprised... By the
I have recently started learning F#, and this is the first time I've ever
I have recently started getting this error while posting to facebook newsfeed stream of
I have recently started doing a little Lua for Minecraft's mod, Computer Craft. I've

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.