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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:37:57+00:00 2026-05-27T01:37:57+00:00

In Javascript, if we have the following code: var j = 0; for(i=0; i<j;

  • 0

In Javascript, if we have the following code:

var j = 0;

for(i=0; i<j; i++){
  //JS Code
}

In this code, on what factors the maximum value of variable j (that is the value upto which browser will not hang) will depend upon (like may be Machine’s RAM or Processor or may be the code being executed in the loop)?

And can this maximum permissible value calculated?

This is required as there is a large array which needs to be processed.

Thanks for any suggestions in advance.

  • 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-27T01:37:58+00:00Added an answer on May 27, 2026 at 1:37 am

    No, you can’t calculate this, it varies too much from browser to browser. Some browsers do it by time (e.g., your code has run for more than X seconds without yielding back to the browser; on Firefox 7 the default is 10 seconds but the user can change it), other browsers do it by number of operations (IE, for instance).

    Your best bet is to refactor your code so you avoid even beginning to approach the limit. If you have a large piece of work to do, break it into chunks, then run the chunks one after another using setTimeout with a timeout value of 0. This yields back to the browser (for more than 0 milliseconds; exactly how long will vary by browser and by what other things are going on on the page).

    Here’s an example of counting to 10,000,000 in 100,000 iteration chunks:

    function toAMillion() {
      var counter = 0,
          limit = 10000000,
          chunk = 100000;
    
      doAChunk();
    
      function doAChunk() {
        var target = Math.min(limit, counter + chunk);
    
        while (counter < target) {
          ++counter;
        }
    
        if (counter < limit) {
          // Schedule next chunk
          setTimeout(doAChunk, 0);
        }
        else {
          // Done
          display("Done, counter = " + counter);
        }
      }
    }
    

    Live copy

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

Sidebar

Related Questions

I have the following code, which will not work. The javascript gives no errors
I have the following code that I am playing with: <script type=text/javascript> var Dash
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==
I have the following JavaScript code: oCoord = {x: null, y: null}; var aStack
I have the following code: http://www.nomorepasting.com/getpaste.php?pasteid=22615 Which is called by the javascript mentioned in
I have the following javascript code, which loads without error, however the update function
I have the following JavaScript code: var ans_el = document.createElement( 'input' ); ans_el.setAttribute( 'id',
UPDATE : I have the following code: <script type=text/javascript> function addScript(url) { var script
A JavaScript newbie here. I have this following code: function testObject(elem) { this.test =
In JavaScript let's say we have the following code var test = 'd'; if

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.