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

224
Visualizações
Javascript - add function to list without triggering it

I'm trying to learn asynchronous programming and so I've been using examples with Python and trying to apply the same for JavaScript, however in Python you can create a list that contains coroutines (async functions) nested inside a list to use asyncio.gather() on. How do you do this in JavaScript. Rest of the code here for added context (in python):

    # Here we create a list that tracks all the async tasks to-do.
    tasks = []
    for i in range(10):
        # Here we add the task of main() function 10 times and add it to the tasks list. Notice that the main is
        # wrapped in []
        tasks += [main(i)]
    # Finally, asyncio gathers the result of all the tasks in the task list. Notice the * asterisk
    await asyncio.gather(*tasks)
async function async_io() {
    let tasks = []
    for (let i = 0; i < 10; i++) {
        tasks.push([main(i)]);
    }
    console.log(tasks)
}
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