Promise.race do in JavaScript?Promise.race returns a new promise that settles as soon as any of the input promises settles (either resolves or rejects). It "races" all promises and settles with the first one that finishes.
Promise.allSettled and Promise.all?Promise.allSettled waits for all promises to settle (resolve or reject) and returns their results regardless of success or failure. Promise.all waits for all to resolve but rejects immediately if any promise rejects.
Promise.allSettled look like?It returns an array of objects, each with a status property ("fulfilled" or "rejected") and either a value (for fulfilled) or reason (for rejected).
You use Promise.race because it settles as soon as any promise settles, whether it resolves or rejects.
Promise.allSettled be used to handle multiple promises without stopping on errors?Yes, Promise.allSettled lets you wait for all promises to finish and see which succeeded or failed without stopping early due to errors.
Promise.race return?Promise.race settles as soon as the first promise settles, returning its result or error.
Promise.allSettled waits for all promises to settle, no matter if they resolve or reject.
Promise.all?Promise.all rejects immediately if any promise rejects.
Promise.allSettled results?The status property is either 'fulfilled' or 'rejected'.
Promise.any returns the first fulfilled promise, ignoring rejected ones.
Promise.race works and give a simple example.Promise.allSettled and how its results are structured.