Web Application Development Latest Feature
I can’t describe it any better than the Mozilla docs: Returns a Promise object that is decide with the given value. If the value is a then-able, the returned promise will “follow” that then able, accepting its conditional state; otherwise the returned promise will be satisfied with the value.
This method is really useful if you are trading with actual functions or services that don’t return a promise. If the value passed in is a promise, cast returns the value, otherwise the value is coerced to a promise. Either way, you can deal with the result as a promise.
Promise.race returns the first promise in the iterable to resolve. Note the use of arrow functions.