JSFiddle - React, Tailwind, and code Playground

by yshrkn

JavaScript

const taskA = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve("taskA's value");
  }, 500);
});

const taskB = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve("taskA's value");
  }, 1000);
});

Promise.all([taskA, taskB]).then((args) => {
  console.log(args); // (2) ["taskA's value", "taskA's value"] 配列として引数を受け取れる。
  console.log('TaskA and B completed.'); // 1秒後に出力される
});