Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const sayHello = () => {
- return new Promise( (resolve, reject) => {
- setTimeout(() => {
- resolve('Hello world');
- }, 500);
- });
- }
- // Declaring an async function
- const printHelloWorld = async () => {
- // Waiting for the promise to be resolved
- result = await sayHello();
- console.log(result);
- }
- printHelloWorld();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement