The Promise.allSettled() method returns a promise that
resolves after all of the given promises have either fulfilled or rejected, with an
array of objects that each describes the outcome of each promise.
developer.mozilla.org
console.log('Vacuuming');constpromise=Promise.resolve().then(()=>console.log('Picking up Milk'));console.log('Washing the Dishes');promise.then(()=>console.log('Take a break'));console.log('Done inside');/*
Output:
"Vacuuming"
"Washing the Dishes"
"Done inside"
"Picking up Milk"
"Take a break"
*/
It's sometimes useful to remember that just because a promise value has settled doesn't mean that it will immediately get processed if something synchronous is currently being processed. One can then onto an already settled promise but the processing will still occur asynchronously.
Just to add:
When a promise is no longer pending it is considered settled.
Promise.allSettled() - JavaScript | MDN
The Promise.allSettled() method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
It's sometimes useful to remember that just because a promise value has settled doesn't mean that it will immediately get processed if something synchronous is currently being processed. One can
then
onto an already settled promise but the processing will still occur asynchronously.Also recursively settling promises is the fastest way to starve the event loop.