SHARE
TWEET

Untitled

a guest Jul 12th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const sayHello = () => {
  2.   return new Promise( (resolve, reject) => {
  3.     setTimeout(() => {
  4.       resolve('Hello world');
  5.     }, 500);
  6.   });
  7. }
  8.  
  9. // Declaring an async function
  10. const printHelloWorld = async () => {
  11.   // Waiting for the promise to be resolved
  12.   result = await sayHello();
  13.   console.log(result);
  14. }
  15.  
  16. printHelloWorld();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top