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

128
Vistas
In Javascript why we use async await while we have promise.all?

In Javascript why we use async await while we have promise.all? I understand that because of chain of promises we use async await but we have promise.all there!? Really confused and stuck over here!

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

0

async/await makes an asynchronous code look like a sequential code, therefore more readable.

Follows an example of asynchronous function that sums two values obtained asynchronously, written using Promise.all:

function sum () {
   return new Promise((resolve, reject) => {
       Promise.all([
           Promise.resolve(3),
           Promise.resolve(4)
       ]).then(values => {
           resolve(values[0] + values[1]);
       })
   })    
}

Now the same function written with async/await:

async function sum () {
    const a = await Promise.resolve(3);
    const b = await Promise.resolve(4);
    return a + b;
}

As you can see, the second function is much more readable and concise.

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