How it works...

Because our main function is marked as async, we are able to use the await operator in its body. This operator causes the function to wait for the result of the expression to be resolved. In our case, this means the Promise created by the async function we called is fulfilled.

Once the result is fulfilled, the control flow continues to the next statement. If we did not use the await operator, the value of randomNumber would be a promise that would resolve to the returned value. We could handle this with the promise interface, but because we used await , we are able to write something that looks more like synchronous code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.166.74