Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

83
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda