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

128
Visualizações
Do these two async functions run in parallel?

Let's say we have two async functions like so:

const getUrl = async () => ...logic

const getName = async () => ...logic

and then I want to define an object which the values of the keys are these functions such as:

const defineObject = async() => {

   const obj = {
      url: await getUrl()
      name: await getName()
   }
}

Is this going to behave as generally JS does where it waits for the first async function to run getUrl() and then runs the second async function getName(), or, does it run them in parallel.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

No, they won't run in parallel. Each use of await turns into a getXXX().then(), with the code after it put into the .then() callback function.

If you want to do that, you can use Promise.all().

const [url, name] = await Promise.all([getUrl(), getName()]);
const obj = {url, name};
about 4 years ago · Santiago Gelvez Relatório
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