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

107
Vistas
prompt loads before anything else

hay if anybody understand why is prompt showing up even before the console printing
i appreciate the help

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promptheadache</title>
</head>

<body>
    <script>
    
        console.log('i should appear first on the console')

        var promptInput = prompt('I\'m am here befor anything else')

    </script>
</body>

</html>

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

console.logs are actually asynchronous in that they are synchronized (as in always in order) but perform an asynchronous call.

prompt is a very old API and one of the few that actually blocks the page - so even-though it appears after the console.log you see it as soon as it is called.

That said - this is not true for every console nor is it guaranteed - the console.log may appear before the prompt depending on the browser/console implementation.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want to get the console before prompt you can add setTimeOut-setTimeout() is an asynchronous function.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promptheadache</title>
</head>

<body>
    <script>
    
        console.log('i should appear first on the console')
  setTimeout(() => {var promptInput = prompt('I\'m am here befor anything else')
},5000) 
 
       

    </script>
</body>

</html>

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