Predict the output of the following javascript code



function asyncFunction(value) {
  return new Promise(resolve => {
    setTimeout(() => {
      console.log(value);
      resolve(value);
    }, 1000);
  });
}

(async () => {
  const results = await Promise.all([asyncFunction(1), asyncFunction(2), asyncFunction(3)]);
  console.log(results);
})();

 

 

 

 

Concurrently executes asyncFunction for values 1, 2, 3, waits for all, then prints their results array. Learn Javascript