Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda