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

224
Vistas
Js executes code that is after a for loop before the loop finish

I know that JavaScript executes loops synchronously. So I don't understand why in the code below alert runs before the end of the for loop. I expected js to first complete the loop and then to execute the alert function. Instead, the for loop starts calling the console.log("loop"), and after a couple of seconds the alert gets executed while at the same time the console.log continuous to print the text "loop".

for(let i=0; i<100000; i++){
  console.log("loop");
}

alert("hello world");

about 4 years ago · Juan Pablo Isaza
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