Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!