/asyncawait.js Secret
Created
April 24, 2022 14:28
This file contains hidden or 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 test(){ | |
await foo(1, 2000) | |
await foo(2, 500) | |
await foo(3, 1000) | |
} | |
function foo(num, sec){ | |
return new Promise(function(resolve, reject){ | |
setTimeout( function(){ | |
console.log(num); | |
resolve("async는 Promise방식을 사용합니다."); | |
}, sec); | |
}); | |
} | |
test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment