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

150
Views
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
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!