[ITEM 2] QUESTION: What are Promise.race, allSettled, and any?
In modern JavaScript, alongside the classic Promise.all, there is a whole range of helper methods for working with collections of asynchronous tasks, each solving specific business needs. The race method is designed for situations where you care about the fastest result, regardless of whether it is successful or erroneous. It returns the first settled promise among the passed ones, whether it's a success or an error, which is often used to implement network request timeouts.
The allSettled method works completely differently; it was added for situations when you need to wait for the completion of absolutely all tasks, regardless of their outcome. The allSettled method waits for all promises and returns an array of objects describing the status of each with either the result value or the error reason. The most important property of this method is that allSettled never rejects with a general promise, making it an indispensable tool for analytics or batch data processing where partial failures should not stop the entire process.
Finally, the any method focuses exclusively on finding the first successful result. It returns the very first successful promise, ignoring any preliminary errors. If all passed tasks fail, the any method rejects, returning a special AggregateError object containing all accumulated errors. This behavior makes any an ideal choice for implementing fallback mechanisms or fetching data from multiple mirrors of the same server.