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

101
Visualizações
How would I make these await functions run sequentially?

I was wondering what was going on in the following code block:

    async function test() {
        function work() {
          console.log("work");
        }

        await setTimeout(work, 5000);
        await setTimeout(work, 1000);
        await setTimeout(work, 5000);
        await setTimeout(work, 1000);
        await console.log("Hello")
      }

This code block takes 5 seconds total to run and 'Hello' is logged immediately, implying all the functions are executing at the same time. How would I make these functions run sequentially without using Promise.all()? Why is this behavior occuring?

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