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

173
Vistas
Evaling async function definitions

I work on an IDE for Javascript that lets developers evaluate their code. In a modern Chrome console, I can run:

eval(`try{function foo3(){console.log("Hi")}} catch(err){console.log(err)}`)

and foo3 will be defined and called fine. I can also run:

eval(`async function foo4(){console.log("Hi")}`)

and foo4 will be defined and called fine. But when I run:

eval(`try{async function foo5(){console.log("Hi")}} catch(err) {console.log(err)}`)

I get no error, but foo5 is not defined. Note that the difference between example 1 and example 3 is just "async" before "function". I would like foo5 to be defined. Clues greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Well, you could invert your code slightly, to include the try/catch block, within your async function to get it going.

eval(`async function foo5() {try {console.log("Hi")} catch (err) { console.log(err)}}`);

foo5();

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