A pending promise can either be fulfilled with a value, or rejected with a reason (error). When either of these options happens, the associated handlers queued up by a promise's then method are called.
A Promise can be in one of the following states
then()clause of promise will be called.
catch()clause of promise will be called.
will handle the errors thrown by the asynchronous flow execution of the Promise where as
try-catch will catch the errors triggered by the synchronous flow
You can also resolve function statically like
Promise.reject() instead of calling the constructor
new Promise((resolve, reject) =>
Unlike callbacks, A promise will be executed as soon as it is encountered.
Await is an ECMAScript
function is a function which is operated asynchronously via event loop returning an AsyncFunction object. It
uses promises to return its result.
await is to get the resultant from the promised function.
Remember, the await keyword is only valid inside async functions. If you use it outside of an async function's body, you will get a SyntaxError.
We shouldn't make it sequentially,
You can clearly see that,
parallel() is twice as fast as
series() is because it is not sequential.
For my new posts, early access to my side projects, and more, get on my private email list, here:subscribe