📜  javascript 等待多个承诺 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:47.612000             🧑  作者: Mango

代码示例1
const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise((resolve, reject) => {
  setTimeout(resolve, 100, 'foo');
});

Promise.all([promise1, promise2, promise3]).then((values) => {
  console.log(values);
});
// expected output: Array [3, 42, "foo"]