Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

332
Views
How to console log numbers from 1 to 1 million efficiently

Javascript code that prints out (using console.log) a sequence of numbers from 1 to 1,000,000 without blocking the interactions with the browser. For example, while that piece of Javascript is running, mouse, keyboard events etc should work fine and browser doesn't hang.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can create a Web worker and let it handle your request in the backend

In your html file

index.html

<script>
 // Check if your browser supports worker
 if (window.Worker) {

 var worker = new Worker('worker.js');
 worker.postMessage("Start Logging");
 }
</script>

worker.js

onmessage = function(e) {
  const result = e.data;
  if(result == "Start Logging"){
    for(let i = 1; i<= 1000000;i++){
      console.log(i)
    }
    postMessage('Done Loggind')
  }
  
}

Web Workers can run your script in background without intercepting your main thread

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!