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

154
Views
Clarification on how asynchronous functions queue with each other

I'm very new to JavaScript, please bear with me if this is quite obvious.

I was watching this video about the event queue and I wrote this code segment to try and see if I understood how JavaScript queues asynchronous functions into their section (I'm not sure what it's called. In the video, it called it a webapi).

setTimeout( () => console.log('hello'), 5000);
setTimeout( () => console.log('123'), 5000);

From my understanding, the first line of code gets sent off to a separate thread where it starts to get evaluated. Then, the second line of code gets sent off to another thread (different from the first) to get evaluated. As each of these evaluations complete in their own separate threads, they will eventually call their callback function, adding it to the task queue, where the event loop will push them back into the main stack.

I'm hoping someone can confirm or correct me on this, and would appreciate any further reading to help solidify this idea. I have to admit, when I first started reading about asynch functions, I was puzzled since I thought JavaScript was single threaded (so how could it yield any benefits?). I know, foolish.

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!