Promise.allSettledの読み方

Promise.allSettledの読み方

javascriptで利用されるメソッドの1つである「Promise.allSettled」の読み方を掲載してます。

読み⽅

プロミス・オールセェトゥルド」と読みます。

英訳

「Settled」は「和解」という意味があります。

Promise.allSettledとは

javascriptで、ES2020の新機能である全てのPromiseが実行されたのちに、成功・失敗が確認できる機能となります。

const sebee1 = Promise.resolve('hoge');
const sebee2 = Promise.reject('foo');
const sebee3 = Promise.resolve('bar');
const promises = [sebee1, sebee2, sebee3];


Promise.allSettled(promises).then((results) => {
    for (const result of results) {
      console.log(result);
    }    
  });

実行結果