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

82
Visualizações
Javascript unexpected identifier but works in console

When I create a script as such

    async function a(){
        return 'a';
    }
    console.log(await a());

The browser (Brave & Edge) gives the error Uncaught SyntaxError: missing ) after argument list

Funnily enough, copy and pasting the exact same code into the debug console runs without a complaint.

Any explanation?

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

0

You can't use await the way you are using it. await should be only used inside of an async function.

try this:

async function a(){
        return 'a';
    }
    console.log(a());
about 4 years ago · Juan Pablo Isaza Relatório

0

There is no need of using await here as we are not returning a promise here. instead try this.

    function a(){
       return 'a';
     }
    console.log(a());

or this if you are learning to use async await and want to use it anyway

async function a(){
    return 'a';
}
const value = await a()
console.log(value);
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