// Promise<String>을 기본적으로 리턴한다
async function helloAsync(){
return delay(3000).then(() =>{
return "hello Async";
});
}
// 위 코드가 너무 거창한거 같은데 await을 사용하면 더 간결하게 코드를 짤 수 있다
async function helloAsync(){
await delay(3000) // await로 부르는 함수는 동기적으로 실행된다.
return "hello Async";
}
function delay(ms){
return new Promise((resolve) =>{
setTimeout(resolve , ms)
})
}
async function main() {
const res = await helloAsync();
console.log(res);
}