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

143
Vistas
javascript executes one function before another whereas I asked the reverse

I have a first function that sends commands and receives data. And a second function to download this data (with href and download). I have a third function that starts function one and then function two but I notice that function two is launched before function one. How do we solve this?

function third(){
    first();
    second();
}
function first(){
//sends and receives commands with websockets
}
function second(){
    console.log("1");
    let save = document.getElementById("photo");
    console.log("2");
    save.href = "http://my_url:my_port/folder/img.jpg";
    console.log("3");
    save.download = "";
    console.log("4");
}

In my console, I can see console.log of the second function before the first function. Why ? Thanks.

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