Created
May 30, 2020 04:26
-
-
Save yussan/8b6452dcdcb8fdb06e9abb7ed33fc74b to your computer and use it in GitHub Desktop.
sample script with and without Async Await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function start() { | |
let x1 = await exe(1); | |
console.log("x1", x1); | |
let x2 = await exe(2); | |
console.log("x2", x2); | |
} | |
function exe(n) { | |
return new Promise((resolve, reject) => { | |
let response; | |
setTimeout(() => { | |
response = `Success ${n}`; | |
resolve(response); | |
}, 1000); | |
}); | |
} | |
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function start() { | |
let x1 = exe(1); | |
console.log("x1", x1); | |
let x2 = exe(2); | |
console.log("x2", x2); | |
} | |
function exe(n) { | |
let response; | |
setTimeout(() => { | |
response = `Success ${n}`; | |
}, 1000); | |
return response; | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment