Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

335
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda