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

198
Visualizações
How do I define AsyncFunction in node?

I am trying to define an AsyncFunction (please note the big F) in node as described here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction

But I get:

AsyncFunction('var1', 'var2', 'let test=var1+var2') (1, 2)
ReferenceError: AsyncFunction is not defined

Creating a normal Function object works fine. Does NodeJS not support AsyncFunction?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think the question you're fundamentally asking is what is the syntax for defining an asynchronous function, and not really trying to invoke the constructor of that object.

if so then:

synchronous:

function foo()

asynchronous:

async function bar()

Update: After understanding your comments, I encourage you to re-read the spec: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction

It clearly describes that it is not a global-scope object. The examples listed below it as well, also describe it's usage which also reinforce the idea that it must be assigned (locally) before usage, so there is a definition of it.

about 4 years ago · Juan Pablo Isaza 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