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

253
Vistas
What is the difference between these two async ternary statements?

Can someone help me understand the difference if any between these two below ternary statements?

const variables = await (conditional ? asyncFunctionOne() : asyncFunctionTwo());
    
const variables = conditional ? await asyncFunctionOne() : await asyncFunctionTwo();

At first glance, these both do the same thing, but some part of me thinks these do not execute in the same order.

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

0

There would be a small difference if this were a function call:

const variables = doSomething(conditional ? functionOne() : functionTwo());
    
const variables = conditional ? doSomething(functionOne()) : doSomething(asyncFunctionTwo());

const temp = conditional ? functionOne() : asyncFunctionTwo();
const variables = doSomething(temp);

These may look equivalent on a first glance, but are not if the code in conditional or even inside functionOne/functionTwo does change the doSomething variable.

However, await is not a function but syntax, its meaning is determined when parsing and compiling the code, not when evaluating it and resolving a variable. So the two lines in your question are absolutely equivalent.

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